diff --git a/ability/ability_runtime/BUILD.gn b/ability/ability_runtime/BUILD.gn index 22edec3e90b4b24b4f4dc28233abf41f66f08556..1dc531055bad1ee3d01e842e6936ce13f90fb0c2 100644 --- a/ability/ability_runtime/BUILD.gn +++ b/ability/ability_runtime/BUILD.gn @@ -43,6 +43,7 @@ group("ability_runtime") { "faapicover:faapicover", "featureability:featureability", "formmanager:formmanager", + "freeinstalltest:freeinstalltest", "killprocesswithaccountstage:killprocesswithaccountstage", "newwant:newwant", "non_concurrent:non_concurrent", diff --git a/ability/ability_runtime/freeinstalltest/BUILD.gn b/ability/ability_runtime/freeinstalltest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2553b8661cf4bc3d25283e28a9edd09227ac37eb --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/BUILD.gn @@ -0,0 +1,71 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +group("freeinstalltest") { + testonly = true + if (is_standard_system) { + deps = [ + "connectabilityfatest/connectdifferentapplication:ConnectDifferentApplication", + "connectabilityfatest/connectfamyapplication1:ConnectFaMyApplication1", + "connectabilityfatest/connectfamyapplication10:ConnectFaMyApplication10", + "connectabilityfatest/connectfamyapplication11:ConnectFaMyApplication11", + "connectabilityfatest/connectfamyapplication2:ConnectFaMyApplication2", + "connectabilityfatest/connectfamyapplication4:ConnectFaMyApplication4", + "connectabilityfatest/connectfamyapplication5:ConnectFaMyApplication5", + "connectabilityfatest/connectfamyapplication6:ConnectFaMyApplication6", + "connectabilityfatest/connectfamyapplication7:ConnectFaMyApplication7", + "connectabilityfatest/connectfamyapplication8:ConnectFaMyApplication8", + "connectabilityfatest/connectfamyapplication9:ConnectFaMyApplication9", + "connectabilityfatest/freeinstallconnectabilityfatest:FreeInstallConnectAbilityFaTest", + "connectabilitystagetest/connectstagemyapplication0:ConnectStageMyApplication0", + "connectabilitystagetest/connectstagemyapplication1:ConnectStageMyApplication1", + "connectabilitystagetest/connectstagemyapplication2:ConnectStageMyApplication2", + "connectabilitystagetest/connectstagemyapplication3:ConnectStageMyApplication3", + "connectabilitystagetest/connectstagemyapplication4:ConnectStageMyApplication4", + "connectabilitystagetest/connectstagemyapplication5:ConnectStageMyApplication5", + "connectabilitystagetest/connectstagemyapplication6:ConnectStageMyApplication6", + "connectabilitystagetest/connectstagemyapplication7:ConnectStageMyApplication7", + "connectabilitystagetest/connectstagemyapplication8:ConnectStageMyApplication8", + "connectabilitystagetest/freeinstallconnectabilitystagetest:FreeInstallConnectAbilityStageTest", + "mockservice:MockService", + "mockservicetimeout:MockServiceTimeout", + "startabilityfatest/atomizationfaentry:AtomizationFaEntry", + "startabilityfatest/atomizationfahm2:AtomizationFaHm2", + "startabilityfatest/atomizationfahm4:AtomizationFaHm4", + "startabilityfatest/famyapplication1:FaMyApplication1", + "startabilityfatest/freeinstallstartabilityfatest:FreeInstallStartAbilityFaTest", + "startabilityfatest/startabilitynotargetbundlelistfatest:StartAbilityNoTargetBundleListFaTest", + "startabilityforresultfatest/atomizationresulta:AtomizationResultA", + "startabilityforresultfatest/atomizationresultfaentry:AtomizationResultFaEntry", + "startabilityforresultfatest/atomizationresultfahm1:AtomizationResultFaHm1", + "startabilityforresultfatest/atomizationresultfahm2:AtomizationResultFaHm2", + "startabilityforresultfatest/faresultmyapplication1:FaResultMyApplication1", + "startabilityforresultfatest/freeinstallstartabilityforresultfatest:FreeInstallStartAbilityForResultFaTest", + "startabilityforresultfatest/startabilityforresultnotargetfatest:StartAbilityForResultNoTargetFaTest", + "startabilityforresultstagetest/atomizationresultstageentry:AtomizationResultStageEntry", + "startabilityforresultstagetest/atomizationresultstagehm2:AtomizationResultStageHm2", + "startabilityforresultstagetest/atomizationresultstagehnm2:AtomizationResultStageHnm2", + "startabilityforresultstagetest/freeinstallstartabilityforresultstagetest:FreeInstallStartAbilityForResultStageTest", + "startabilityforresultstagetest/stageresultmyapplication1:StageResultMyApplication1", + "startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest:StartAbilityForResultNoTargetBundleListStageTest", + "startabilitystagetest/atomizationstageentry:AtomizationStageEntry", + "startabilitystagetest/atomizationstagehm2:AtomizationStageHm2", + "startabilitystagetest/atomizationstagehm4:AtomizationStageHm4", + "startabilitystagetest/freeinstallstartabilitystagetest:FreeInstallStartAbilityStageTest", + "startabilitystagetest/stagemyapplication1:StageMyApplication1", + "startabilitystagetest/startabilitynotargetbundleliststagetest:StartAbilityNoTargetBundleListStageTest", + ] + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..e9ff23fb9982d00627feac5338d4610b96de117f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.different.hmservice", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ca7865286b64b0cab24ee825460a12e4a8138f69 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "different" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..531c048f4b983b7defe15fd40a7d4ccdec5fc58a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectDifferentApplication") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectdifferentapplication_js_assets", + ":connectdifferentapplication_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectDifferentApplication" +} + +ohos_app_scope("connectdifferentapplication_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectdifferentapplication_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectdifferentapplication_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectdifferentapplication_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..9090e1e7a8394d1a945a06bf33cd1931f5da367d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] diffentry MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..a3b93f8a076da63136ae275c28ebec9ba032ddeb --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] diffentry MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] diffentry MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] diffentry MainAbility onWindowStageCreate") + globalThis.different = this.context; + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] diffentry MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] diffentry MainAbility onForeground") + setTimeout(function () { + globalThis.different.terminateSelf() + .then((data) => { + console.info('[Demo] myapp2 terminateself succeeded: ' + data); + }).catch((error) => { + console.error('[Demo] myapp2 terminateself failed. Cause: ' + error); + }) + }, 3200); + } + + onBackground() { + // Ability has back to background + console.log("[Demo] diffentry MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9cd0c5abef23f04446dace09224b5b25b60958af --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility feature onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility feature op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility different onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility different onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility different onConnect'); + console.info('stage_connectAbility connect different success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility different onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility different onReconnect'); + } + onDestroy() { + console.info('ServiceAbility different onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..977d8dd2a8bbaf896395737ad56be01ff611ed9f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 different' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..8f91deeb5036e3c086c8cf2dd76f7cc48db8bbd9 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/module.json @@ -0,0 +1,49 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "com.example.different.ServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_FormAbility_label", + "description": "$string:form_FormAbility_desc", + "type": "service", + "visible": true, + "icon": "$media:icon" + + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b8416b237de5fe166d47eb8720d73a089b6d9fe0 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectdifferentapplication/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..7c38a33828c4c9599c824c86b96a5797bb9c0d64 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication1") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication1_ets_assets", + ":connectfamyapplication1_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication1" +} +ohos_js_assets("connectfamyapplication1_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication1_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..703f0577eae146eaa0b690c75865e82df32afe55 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility_feature", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication1" + }, + "package": "com.example.myapplication1", + "srcPath": "", + "name": ".myapplication1", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ada8c9177f629fdda43e5a1ecff2acb9fa0fd937 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp1' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..0f2aea022b0a8123e8eaedec486621d95c9a1505 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp1 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp1 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp1 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp1 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp1 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp1 onConnect'); + console.info('featureAbility_connectAbility connect myapp1 Servcie_feature success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp1 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..38597b2a7f72c119a27e63e6fead352c3287db83 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication1_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication1/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bc700006dad8c91eea07dce3741138b587b760d1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication10") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication10_ets_assets", + ":connectfamyapplication10_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication10" +} +ohos_js_assets("connectfamyapplication10_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication10_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..c9c5fcbc8c1809937dd4ad3233f736d4d53af693 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication10" + }, + "package": "com.example.myapplication10", + "srcPath": "", + "name": ".myapplication10", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3307757f47c3ea3f04f3e292301c889ea07fe3b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp10' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..340d7724cf21c73e4d2d3292b031ccbf27b3f97e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp10 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp10 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp10 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp10 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp10 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp10 onConnect'); + console.info('featureAbility_connectAbility connect myapp10 Servcie success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp10 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4c421403121234bb7e597fb9211cb1de0922936f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication10_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication10/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b06532fa5312c509efb922c185cc846f8750bf37 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication11") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication11_ets_assets", + ":connectfamyapplication11_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication11" +} +ohos_js_assets("connectfamyapplication11_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication11_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..479a7ba322aa1f377769d0e16b288179fcab7d56 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication11" + }, + "package": "com.example.myapplication11", + "srcPath": "", + "name": ".myapplication11", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ef08babe1b4adee028a3fa074d75b26a818afd1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp11' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..89c989ba170006c1ee086da8096a77807ae43b83 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp11 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp11 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp11 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp11 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp11 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp11 onConnect'); + console.info('featureAbility_connectAbility connect myapp11 Servcie success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp11 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..26ca9c0a403faacb0549b20386008f959f45c8d7 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication11_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication11/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..c5c3c224464af681532c184384158c1ff998d703 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication2") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication2_ets_assets", + ":connectfamyapplication2_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication2" +} +ohos_js_assets("connectfamyapplication2_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication2_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..7f010dcdae4e669ff6d6f705646d921cbed6f850 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication2" + }, + "package": "com.example.myapplication2", + "srcPath": "", + "name": ".myapplication2", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..877e6cecc54092d17ce8d578c97cdff721fe371e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import featureAbility from '@ohos.ability.featureAbility'; +export default { + onCreate() { + console.info('Application onCreate') + setTimeout(function () { + featureAbility.terminateSelf() + .then((data) => { + console.info('[Demo] myapp2 terminateself succeeded: ' + data); + }).catch((error) => { + console.error('[Demo] myapp2 terminateself failed. Cause: ' + error); + }) + }, 3200); + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f010fbe82e4c98fd7421e8110c04033ecf59a42 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp2' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..716e96e3b26c6674ccc53ffc31213ae79fef28bc --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp2 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp2 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp2 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp2 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp2 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp2 onConnect'); + console.info('featureAbility_connectAbility connect myapp2 Servcie_feature success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp2 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..6fee754925c51d733495347726d50aca20848460 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication2_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ae6cefcef484faa901659267384bf04a996238e2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication4") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication4_ets_assets", + ":connectfamyapplication4_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication4" +} +ohos_js_assets("connectfamyapplication4_ets_assets") { + source_dir = "./entry/src/main/ets/" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication4_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d1f33c1f4ebdb047fa85ae995612dddcd86100e4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility4", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication4" + }, + "package": "com.example.myapplication4", + "srcPath": "", + "name": ".myapplication4", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb6a4119b8674ac5f03e0a811e7c3e03640e80fe --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp4' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..c10afde98e55ad6412dbce64122e692d70982cd7 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp4 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp4 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp4 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp4 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp4 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp4 onConnect'); + console.info('featureAbility_connectAbility connect myapp4 Servcie_feature success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp4 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..7b9146ae914d377114c05e3fa217c9b9f44ef7d9 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication4_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication4/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..de3b2ad1df75ccdbd74981829e208a8319a5658c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication5") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication5_ets_assets", + ":connectfamyapplication5_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication5" +} +ohos_js_assets("connectfamyapplication5_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication5_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..7a109ddf89c5462ed09dcd56abac2e780b08fceb --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility5", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication5" + }, + "package": "com.example.myapplication5", + "srcPath": "", + "name": ".myapplication5", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..cda4beb8e07e4768923f0f9ca8832bdf9d6b0338 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp5' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..56bae95a348f2fca563313055fc6a4f42f31de66 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp5 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp5 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp5 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp5 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp5 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp5 onConnect'); + console.info('featureAbility_connectAbility connect myapp5 Servcie_feature success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp5 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..58bc2cdcb3d88594a88d34432808b8debd2b066f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication5_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication5/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..cb490fdb67dbd7bf7d49e2d48f671be61b482b2f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication6") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication6_ets_assets", + ":connectfamyapplication6_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication6" +} +ohos_js_assets("connectfamyapplication6_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication6_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..6d5e2c816058156690c09c387696e3be51590203 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication6" + }, + "package": "com.example.myapplication6", + "srcPath": "", + "name": ".myapplication6", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f3fc266d0d500984fabc686d7cfc2e8822ba92a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp0' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..9db1ce4aa08bc47fd4fd51a62f5fd6c77260ea21 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp0 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp0 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp0 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp0 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp0 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp0 onConnect'); + console.info('featureAbility_connectAbility connect myapp0 Servcie_feature success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp0 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..358d583e43049db3dd397f84b1e4419a2de79d09 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication6_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication6/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..07ac4d178905c46afcd6a6b73bc64baa174b75de --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication7") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication7_ets_assets", + ":connectfamyapplication7_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication7" +} +ohos_js_assets("connectfamyapplication7_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication7_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..d9aa6532c25b50ebafc085db7afd2e7b04b9c810 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication7" + }, + "package": "com.example.myapplication7", + "srcPath": "", + "name": ".myapplication7", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..475e1004167ccb883a98052cdc174902e10d5079 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp7' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..fdcf68275232a43f817d80a53759cde7b13a62ea --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp7 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp7 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp7 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp7 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp7 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp7 onConnect'); + console.info('featureAbility_connectAbility connect myapp7 Servcie_feature success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp7 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..bbe38ba483747a910a4b3a2a780b9013da9768f5 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication7_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication7/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..ca3a8cdfbff781085dd459ecd5345285673499ee --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication8") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication8_ets_assets", + ":connectfamyapplication8_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication8" +} +ohos_js_assets("connectfamyapplication8_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication8_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..bc9ea9babe948f2c9e1179f0227ee3a07d5662c1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication8" + }, + "package": "com.example.myapplication8", + "srcPath": "", + "name": ".myapplication8", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..76e7f5e858ef0d5f33618356a55980c442756547 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp8' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..46d0246f1fd1bf274c460d174b61caae5d1b6c3d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp8 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp8 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp8 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp8 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp8 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp8 onConnect'); + console.info('featureAbility_connectAbility connect myapp8 Servcie_feature success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp8 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b4427ba9f5c94c5305b1a25ea1a12250c0c0e02b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication8_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication8/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..6e3d001cb5ebd46e34b72cc87dcded3bc7f22069 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectFaMyApplication9") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":connectfamyapplication9_ets_assets", + ":connectfamyapplication9_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "ConnectFaMyApplication9" +} +ohos_js_assets("connectfamyapplication9_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("connectfamyapplication9_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..757fd90f50233b0c623bb58343119bbf2b1e4484 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/config.json @@ -0,0 +1,81 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication9" + }, + "package": "com.example.myapplication9", + "srcPath": "", + "name": ".myapplication9", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..618fde745a8a1729e1fe1e08eb82c4495e4ebe7c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp9' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..58625965e286a0c62e21b01d7c71d5d3a4316e6e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp9 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp9 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} + +export default { + onStart() { + console.info('ServiceAbility myapp9 onStart'); + }, + onStop() { + console.info('ServiceAbility myapp9 onStop'); + }, + onCommand(want, startId) { + console.info('ServiceAbility myapp9 onCommand'); + }, + onConnect(want) { + console.info('ServiceAbility myapp9 onConnect'); + console.info('featureAbility_connectAbility connect myapp9 Servcie success'); + return new StubTest("1"); + }, + onDisConnect(want) { + console.info('ServiceAbility myapp9 onDisConnect'); + }, +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..aef493b65f391b62e6ae6eb7aee7ea5225cefe27 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "myapplication9_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/connectfamyapplication9/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d15d2df4219daa703f0f69420f1e8fc001ff23d2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FreeInstallConnectAbilityFaTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":freeinstallconnectabilityfatest_ets_assets", + ":freeinstallconnectabilityfatest_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FreeInstallConnectAbilityFaTest" +} +ohos_js_assets("freeinstallconnectabilityfatest_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("freeinstallconnectabilityfatest_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/Test.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..a473fdecb86d9fb6a6a7e26e8c0a3f380c010657 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/Test.json @@ -0,0 +1,43 @@ +{ + "description": "Configuration for freeinstallconnectabilityfatest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.myapplication.hmservice", + "package-name": "com.example.myapplication", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "FreeInstallConnectAbilityFaTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "MockService.hap -> /data/test/MockService.hap", + "ConnectFaMyApplication1.hap -> /data/test/ConnectFaMyApplication1.hap", + "ConnectFaMyApplication2.hap -> /data/test/ConnectFaMyApplication2.hap", + "ConnectFaMyApplication4.hap -> /data/test/ConnectFaMyApplication4.hap", + "ConnectFaMyApplication5.hap -> /data/test/ConnectFaMyApplication5.hap", + "ConnectFaMyApplication6.hap -> /data/test/ConnectFaMyApplication6.hap", + "ConnectFaMyApplication7.hap -> /data/test/ConnectFaMyApplication7.hap", + "ConnectFaMyApplication8.hap -> /data/test/ConnectFaMyApplication8.hap", + "ConnectFaMyApplication9.hap -> /data/test/ConnectFaMyApplication9.hap", + "ConnectFaMyApplication10.hap -> /data/test/ConnectFaMyApplication10.hap", + "ConnectFaMyApplication11.hap -> /data/test/ConnectFaMyApplication11.hap", + "ConnectDifferentApplication.hap -> /data/test/ConnectDifferentApplication.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..02cfb86b4cd2bb7b361e1c31ad714abf28e85576 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/config.json @@ -0,0 +1,187 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.example.myapplication.hmservice", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "srcPath": "MainAbility2", + "name": ".MainAbility2", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility2_desc", + "formsEnabled": false, + "label": "$string:MainAbility2_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility2", + "name": ".ServiceAbility2", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility2_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility3", + "name": ".ServiceAbility3", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility3_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility4", + "name": ".ServiceAbility4", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility4_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility5", + "name": ".ServiceAbility5", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility5_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility6", + "name": ".ServiceAbility6", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility6_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility7", + "name": ".ServiceAbility7", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility7_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility8", + "name": ".ServiceAbility8", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility8_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility9", + "name": ".ServiceAbility9", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility9_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility10", + "name": ".ServiceAbility10", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility10_desc", + "type": "service" + }, + { + "srcPath": "ServiceAbility11", + "name": ".ServiceAbility11", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility11_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "entry", + "installationFree": false, + "deliveryWithInstall": true, + "moduleName": "entry" + }, + "package": "com.example.myapplication", + "srcPath": "", + "name": ".entry", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility2", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..b8268c790ba573ec5764c2683b721eb41d3882b0 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,28 @@ +/** + * Copyright (c) 2022 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 commonEvent from '@ohos.commonEvent' + +export default { + onCreate() { + console.info('Application onCreate') + commonEvent.publish("test_data", () => { + console.log("freeInstall commonEvent.publish success!") + }); + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3efa07583577fab3dd6f797ee79a54a474983d8f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,63 @@ +// @ts-nocheck +/** + * Copyright (c) 2022 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 file from '@system.file'; +import {Core, ExpectExtend, ReportExtend} from "deccjsunit/index.ets"; +import testsuite from "../test/List.test"; +import featureAbility from "@ohos.ability.featureAbility"; +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + Want.parameters.timeout = 10000; + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/ConnectAbilityTest.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/ConnectAbilityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e6e844df4669869e040e644ab7450e1a2f0c062 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/ConnectAbilityTest.ets @@ -0,0 +1,628 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 "deccjsunit/index" +import rpc from '@ohos.rpc'; +import featureAbility from '@ohos.ability.featureAbility'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; +import abilityManager from '@ohos.application.abilityManager'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + + +export default function ConnectAbilityTest() { + var TAG = ""; + var Tempassert = ""; + var abilityDelegator = undefined + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + describe('FreeInstall_FA_ConnectAbility', function () { + beforeAll(async function (done) { + console.info("FreeInstall_FA_ConnectAbility before all called"); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator)); + abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("FreeInstall_FA_ConnectAbility after each called"); + Tempassert = "" + await sleep(1000); + done(); + }); + + function tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } + + async function connectabillity(msg, request) { + console.info(msg + "START"); + let options = { + onConnect: function (element, proxy) { + console.info("FreeInstall_FA_ConnectAbility onConnect success!!!") + console.info(msg + " onConnect success!!! "); + console.info(msg + " onConnect: " + JSON.stringify(element)); + console.info(msg + " onConnect: " + JSON.stringify(proxy)); + if (proxy == null) { + console.error("FreeInstall_FA_ConnectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + Tempassert = "onConnect"; + tips("连接成功"); + }, + onDisconnect: function (element) { + console.info("FreeInstall_FA_ConnectAbility onDisconnect success!!!") + console.info(msg + " onDisconnect success!!!"); + console.info(msg + " onDisconnect: " + JSON.stringify(element)); + Tempassert = "onDisconnect"; + tips("连接断开"); + }, + onFailed: function (code) { + console.info("FreeInstall_FA_ConnectAbility onFailed!!!") + console.info(msg + " onFailed!!! "); + console.info(msg + " onFailed: " + JSON.stringify(code)); + Tempassert = "onFailed"; + tips("连接失败"); + } + } + let connection = await featureAbility.connectAbility(request, options); + console.info(msg + "request:" + JSON.stringify(request)); + console.info(msg + "options:" + JSON.stringify(options)); + console.info(msg + "connection=" + JSON.stringify(connection)); + console.info(msg + "END"); + } + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0100 + * @tc.name Pass in the local deviceid,atomic service does not exist locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_0100", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0100-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0100"; + var cmd4 = "cp data/test/ConnectFaMyApplication6.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps" + + "/entry/files"; + abilityDelegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info(TAG + " executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var deviceid = "0"; + abilityManager.getTopAbility((err, data) => { + console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err)); + console.log(TAG + 'getTopAbility result deviceid:' + JSON.stringify(data.ability.deviceId)); + deviceid = data.ability.deviceId; + }) + await sleep(500); + var request1 = { + "deviceId": deviceid, + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication6.ServiceAbility", + "moduleName": "myapplication6", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request1); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_0100-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0200 + * @tc.name Pass in the local deviceid,atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_0200", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0200-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0200"; + var cmdapp10 = "bm install -p data/test/ConnectFaMyApplication10.hap"; + abilityDelegator.executeShellCommand(cmdapp10, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var deviceid = "0"; + abilityManager.getTopAbility((err, data) => { + console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err)); + console.log(TAG + 'getTopAbility result deviceid:' + JSON.stringify(data.ability.deviceId)); + deviceid = data.ability.deviceId; + }) + await sleep(500); + var request2 = { + "deviceId": deviceid, + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication10.ServiceAbility", + "moduleName": "myapplication10", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request2); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_0200-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0300 + * @tc.name Deviceid is empty,atomic service does not exist locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_0300", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0300-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0300"; + var cmd3 = "cp data/test/ConnectFaMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + abilityDelegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var request3 = { + "deviceId": "", + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication1.ServiceAbility_feature", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request3); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_0300-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0400 + * @tc.name Deviceid is empty,atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_0400", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0400-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0400"; + var cmdapp11 = "bm install -p data/test/ConnectFaMyApplication11.hap"; + abilityDelegator.executeShellCommand(cmdapp11, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var request4 = { + "deviceId": "", + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication11.ServiceAbility", + "moduleName": "myapplication11", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request4); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_0400-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0500 + * @tc.name The bundleName passed in is different from the local + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_0500", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0500-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0500"; + var request5 = { + "bundleName": "com.example.different.hmservice", + "abilityName": "com.example.different.ServiceAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request5); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_0500-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0600 + * @tc.name Pass in an empty bundleName + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_0600", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0600-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0600"; + var request6 = { + "bundleName": "", + "abilityName": "com.example.myapplication1.ServiceAbility_feature", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request6); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_0600-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0700 + * @tc.name Pass in an empty abilityName + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_0700", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0700-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0700"; + var request7 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request7); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_0700-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0800 + * @tc.name Incorrect deviceid passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_0800", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0800-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0800"; + var request8 = { + "deviceId": "xxxxxx", + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication2.ServiceAbility", + "moduleName": "myapplication2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request8); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_0800-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_0900 + * @tc.name Incorrect bundleName passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_0900", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_0900-------------"); + TAG = "FreeInstall_FA_ConnectAbility_0900"; + var request9 = { + "bundleName": "com.example.xxx.hmservice", + "abilityName": "com.example.myapplication2.ServiceAbility", + "moduleName": "myapplication2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request9); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_0900-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1000 + * @tc.name Incorrect flags passed in,atomic service does not exist locally + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_1000", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1000-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1000"; + var request10 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication2.ServiceAbility", + "moduleName": "myapplication2", + "flags": 1111111, + } + connectabillity(TAG, request10); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_1000-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1100 + * @tc.name Incorrect flags passed in,atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_1100", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1100-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1100"; + var cmdapp2 = "bm install -p data/test/ConnectFaMyApplication2.hap"; + abilityDelegator.executeShellCommand(cmdapp2, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var request11 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication2.ServiceAbility", + "moduleName": "myapplication2", + "flags": "11", + } + connectabillity(TAG, request11); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_1000-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1200 + * @tc.name No atomic service under path + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_1200", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1200-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1200"; + var cmdrm = "rm -r /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/*"; + abilityDelegator.executeShellCommand(cmdrm, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var request12 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication1.ServiceAbility_feature", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request12); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_1200-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1300 + * @tc.name The application is not in the foreground [start MainAbility2 first, then connect] + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_1300", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1300-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1300"; + var str = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.MainAbility2", + } + } + console.info(TAG + " startmainability2 str: " + JSON.stringify(str)); + featureAbility.startAbility(str) + .then((data) => { + console.info(TAG + " startmainability2 successful. Data: " + JSON.stringify(data)) + }).catch((error) => { + console.error(TAG + " startmainability2 failed. Cause: " + JSON.stringify(error)); + }) + await sleep(1500); + var request13 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication1.ServiceAbility_feature", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request13); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_1300-------------"); + done(); + }, 1500); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1400 + * @tc.name The application is not in the foreground [start myapp2 first, then connect] + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_1400", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1400-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1400"; + var str = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication2.MainAbility", + } + } + console.info(TAG + " startmyapp2 str: " + JSON.stringify(str)); + featureAbility.startAbility(str) + .then((data) => { + console.info(TAG + " startmyapp2 successful. Data: " + JSON.stringify(data)) + }).catch((error) => { + console.error(TAG + " startmyapp2 failed. Cause: " + JSON.stringify(error)); + }) + await sleep(1500); + var request14 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication1.ServiceAbility_feature", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request14); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_1400-------------"); + done(); + }, 1500); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1700 + * @tc.name Do not pass flags, connect to the service of another project + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_1700", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1700-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1700"; + var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap"; + abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var request17 = { + "bundleName": "com.example.different.hmservice", + "abilityName": "com.example.different.ServiceAbility", + "moduleName": "entry", + } + connectabillity(TAG, request17); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_1700-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1800 + * @tc.name Incorrect moduleName passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_1800", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1800-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1800"; + var request18 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication1.ServiceAbility_feature", + "moduleName": "xxxxx", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request18); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_1800-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1900 + * @tc.name The target is atomized as hapA, and hapB is placed under the path + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_1900", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1900-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1900"; + var cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var request19 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication1.ServiceAbility_feature", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request19); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_1900-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_2000 + * @tc.name Pass in parameters + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_2000", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_2000-------------"); + TAG = "FreeInstall_FA_ConnectAbility_2000"; + var cmdmyapp5 = "cp data/test/ConnectFaMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + abilityDelegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var request20 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication5.ServiceAbility5", + "moduleName": "myapplication5", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + "parameters": { + "name": 1111, "key1": "value1", "site": "nice to meet you!" + }, + } + connectabillity(TAG, request20); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_2000-------------"); + done(); + }, 2000); + }); + } + ) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/ConnectAbilityTest1.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/ConnectAbilityTest1.ets new file mode 100644 index 0000000000000000000000000000000000000000..d3232ec906ff4fc9e8c3200ba1ef8992b465f8de --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/ConnectAbilityTest1.ets @@ -0,0 +1,202 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 "deccjsunit/index" +import rpc from '@ohos.rpc'; +import featureAbility from '@ohos.ability.featureAbility'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + + +export default function ConnectAbilityTest1() { + var TAG = ""; + var Tempassert = ""; + var abilityDelegator = undefined + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + describe('FreeInstall_FA_ConnectAbility', function () { + beforeAll(async function (done) { + console.info("FreeInstall_FA_ConnectAbility before all called"); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + console.info(TAG + " abilityDelegator : " + JSON.stringify(abilityDelegator)); + abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("FreeInstall_FA_ConnectAbility after each called"); + Tempassert = "" + await sleep(1000); + done(); + }); + + function tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } + + async function connectabillity(msg, request) { + console.info(msg + "START"); + let options = { + onConnect: function (element, proxy) { + console.info("FreeInstall_FA_ConnectAbility onConnect success!!!") + console.info(msg + " onConnect success!!! "); + console.info(msg + " onConnect: " + JSON.stringify(element)); + console.info(msg + " onConnect: " + JSON.stringify(proxy)); + if (proxy == null) { + console.error("FreeInstall_FA_ConnectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + Tempassert = "onConnect"; + tips("连接成功"); + }, + onDisconnect: function (element) { + console.info("FreeInstall_FA_ConnectAbility onDisconnect success!!!") + console.info(msg + " onDisconnect success!!!"); + console.info(msg + " onDisconnect: " + JSON.stringify(element)); + Tempassert = "onDisconnect"; + tips("连接断开"); + }, + onFailed: function (code) { + console.info("FreeInstall_FA_ConnectAbility onFailed!!!") + console.info(msg + " onFailed!!! "); + console.info(msg + " onFailed: " + JSON.stringify(code)); + Tempassert = "onFailed"; + tips("连接失败"); + } + } + let connection = await featureAbility.connectAbility(request, options); + console.info(msg + "request:" + JSON.stringify(request)); + console.info(msg + "options:" + JSON.stringify(options)); + console.info(msg + "connection=" + JSON.stringify(connection)); + console.info(msg + "END"); + } + + + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1500 + * @tc.name The application is not in the foreground, + [start another project first, then connect,atomic service does not exist locally] + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_1500", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1500-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1500"; + var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap"; + abilityDelegator.executeShellCommand(cmddif, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var str = { + "want": { + "bundleName": "com.example.different.hmservice", + "abilityName": "MainAbility", + } + }; + featureAbility.startAbility(str) + .then((data) => { + console.info(TAG + " startother successful. Data: " + JSON.stringify(data)) + }).catch((error) => { + console.error(TAG + " startother failed. Cause: " + JSON.stringify(error)); + }) + await sleep(1500); + var request15 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication5.ServiceAbility5", + "moduleName": "myapplication5", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request15); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_1500-------------"); + done(); + }, 1500); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_1600 + * @tc.name The application is not in the foreground, + [start another project first, then connect,atomic service exists locally] + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_1600", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_1600-------------"); + TAG = "FreeInstall_FA_ConnectAbility_1600"; + var cmdmyapp4 = "bm install -p data/test/ConnectFaMyApplication4.hap"; + abilityDelegator.executeShellCommand(cmdmyapp4, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var str = { + "want": { + "bundleName": "com.example.different.hmservice", + "abilityName": "MainAbility", + } + }; + featureAbility.startAbility(str) + .then((data) => { + console.info(TAG + " startother successful. Data: " + JSON.stringify(data)) + }).catch((error) => { + console.error(TAG + " startother failed. Cause: " + JSON.stringify(error)); + }) + await sleep(1500); + var request16 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication4.ServiceAbility4", + "moduleName": "myapplication4", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request16); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_1600-------------"); + done(); + }, 1500); + }); + } + ) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f2b84b5796ddac70ace6d58750429150c694a266 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2022 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 ConnectAbilityTest1 from './ConnectAbilityTest1' +import ConnectAbilityTest from './ConnectAbilityTest' +import connectAbilityTest_PA from './connectAbilityTest_PA' + +export default function testsuite() { + ConnectAbilityTest1(); + ConnectAbilityTest(); + connectAbilityTest_PA(); + +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/connectAbilityTest_PA.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/connectAbilityTest_PA.ets new file mode 100644 index 0000000000000000000000000000000000000000..54120ab10b5a009f18e9c150f7427e78981a06a5 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility/test/connectAbilityTest_PA.ets @@ -0,0 +1,442 @@ +// @ts-nocheck +/** + * Copyright (c) 2022 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 "deccjsunit/index" +import featureAbility from '@ohos.ability.featureAbility'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import commonEvent from '@ohos.commonEvent'; + +export default function connectAbilityTest_PA() { + var TAG = ""; + var dataAssert = ""; + var abilityDelegator = undefined + var subscriber; + var subscribeInfo = { + events: ["service_event", "service2_event", "service3_event", "service4_event", "service5_event", + "service6_event", "service7_event", "service8_event", "service9_event", "service10_event", "service11_event"] + }; + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + async function startService(msg, str) { + console.info(msg + ' startService successful. str: ' + JSON.stringify(str)); + featureAbility.startAbility(str) + .then((data) => { + console.info(msg + ' startService successful. Data: ' + JSON.stringify(data)); + }).catch((error) => { + console.error(msg + ' startService failed. Cause: ' + JSON.stringify(error)); + }) + } + + function checkParameters(msg1, data) { + for (var key in data.parameters) { + console.info(msg1 + " data.parameters is : " + data.parameters[key]) + if (data.parameters[key] === "onFailed") { + dataAssert = "onFailed"; + } else if (data.parameters[key] === "onDisconnect") { + dataAssert = "onDisconnect"; + } else if (data.parameters[key] === "onConnect") { + dataAssert = "onConnect"; + } + } + } + + function SubscribeCallBack(err, data) { + if (err.code) { + console.error("commonEvent subscribe failed " + JSON.stringify(err)); + } else { + if (data.event === "service_event") { + console.info("commonEvent subscribe service " + JSON.stringify(data)); + checkParameters("commonEvent service", data) + } else if (data.event === "service2_event") { + console.info("commonEvent subscribe service2 " + JSON.stringify(data)); + checkParameters("commonEvent service2", data) + } else if (data.event === "service3_event") { + console.info("commonEvent subscribe service3 " + JSON.stringify(data)); + checkParameters("commonEvent service3", data) + } else if (data.event === "service4_event") { + console.info("commonEvent subscribe service4 " + JSON.stringify(data)); + checkParameters("commonEvent service4", data) + } else if (data.event === "service5_event") { + console.info("commonEvent subscribe service5 " + JSON.stringify(data)); + checkParameters("commonEvent service5", data) + } else if (data.event === "service6_event") { + console.info("commonEvent subscribe service6 " + JSON.stringify(data)); + checkParameters("commonEvent service6", data) + } else if (data.event === "service7_event") { + console.info("commonEvent subscribe service7 " + JSON.stringify(data)); + checkParameters("commonEvent service7", data) + } else if (data.event === "service8_event") { + console.info("commonEvent subscribe service8 " + JSON.stringify(data)); + checkParameters("commonEvent service8", data) + } else if (data.event === "service9_event") { + console.info("commonEvent subscribe service9 " + JSON.stringify(data)); + checkParameters("commonEvent service9", data) + } else if (data.event === "service10_event") { + console.info("commonEvent subscribe service10 " + JSON.stringify(data)); + checkParameters("commonEvent service10", data) + } else if (data.event === "service11_event") { + console.info("commonEvent subscribe service11 " + JSON.stringify(data)); + checkParameters("commonEvent service11", data) + } + } + } + + + function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("commonEvent createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("----commonEvent createSubscriber------"); + subscriber = commonEventSubscriber; + commonEvent.subscribe(subscriber, SubscribeCallBack); + } + } + + describe('FreeInstall_FA_ConnectAbility_PA', function () { + beforeAll(async function (done) { + console.info("FreeInstall_FA_ConnectAbility_PA before all called"); + console.info("FreeInstall_FA_ConnectAbility_PA commonEvent.createSubscriber start!!!"); + commonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); + await sleep(2000); + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + abilityDelegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + abilityDelegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + abilityDelegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + + }) + await sleep(500); + var cmdum = "bm uninstall -n com.example.different.hmservice"; + abilityDelegator.executeShellCommand(cmdum, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("FreeInstall_FA_ConnectAbility_PA after each called"); + dataAssert = "" + await sleep(1000); + done(); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0100 + * @tc.name Deviceid is empty,atomic service does not exist locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_PA_0100", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0100-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0100"; + var cmdmyapp7 = "cp data/test/ConnectFaMyApplication7.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + abilityDelegator.executeShellCommand(cmdmyapp7, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var str1 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility", + } + }; + startService(TAG, str1); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0100-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0200 + * @tc.name Deviceid is empty,atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_PA_0200", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0200-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0200"; + var cmdapp9 = "bm install -p data/test/ConnectFaMyApplication9.hap"; + abilityDelegator.executeShellCommand(cmdapp9, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var str2 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility2", + } + }; + startService(TAG, str2); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0200-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0300 + * @tc.name The bundleName passed in is different from the local + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_PA_0300", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0300-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0300"; + var str3 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility3", + } + }; + startService(TAG, str3); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0300-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0400 + * @tc.name Do not pass flags, atomic service does not exist locally + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_PA_0400", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0400-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0400"; + var str4 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility4", + } + }; + startService(TAG, str4); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0400-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0500 + * @tc.name Do not pass flags, atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_PA_0500", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0500-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0500"; + var cmdin = "bm install -p data/test/ConnectDifferentApplication.hap"; + abilityDelegator.executeShellCommand(cmdin, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var str5 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility5", + } + }; + startService(TAG, str5); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0500-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0600 + * @tc.name Incorrect deviceid passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_PA_0600", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0600-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0600"; + var str6 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility6", + } + }; + startService(TAG, str6); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0600-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0700 + * @tc.name Incorrect bundleName passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_PA_0700", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0700-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0700"; + var str7 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility7", + } + }; + startService(TAG, str7); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0700-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0800 + * @tc.name Pass in an empty abilityName + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_PA_0800", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0800-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0800"; + var str8 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility8", + } + }; + startService(TAG, str8); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0800-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_0900 + * @tc.name No atomic service under path + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_PA_0900", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_0900-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_0900"; + var cmdrm = "rm -r /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/*"; + abilityDelegator.executeShellCommand(cmdrm, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var str9 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility9", + } + }; + startService(TAG, str9); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_0900-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_1000 + * @tc.name Incorrect moduleName passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_FA_ConnectAbility_PA_1000", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_1000-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_1000"; + var str10 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility10", + } + }; + startService(TAG, str10); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_1000-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_ConnectAbility_PA_1100 + * @tc.name Pass in parameters + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_ConnectAbility_PA_1100", 0, async function (done) { + console.log("------------start FreeInstall_FA_ConnectAbility_PA_1100-------------"); + TAG = "FreeInstall_FA_ConnectAbility_PA_1100"; + var cmdmyapp8 = "cp data/test/ConnectFaMyApplication8.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + abilityDelegator.executeShellCommand(cmdmyapp8, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var str11 = { + "want": { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility11", + } + }; + startService(TAG, str11); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_FA_ConnectAbility_PA_1100-------------"); + done(); + }, 4000); + }); + } + ) +} + diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility2/app.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility2/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa1409851eb7fb28004f07317e1dfda41bba854e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility2/app.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import featureAbility from '@ohos.ability.featureAbility'; +export default { + onCreate() { + console.info('Application onCreate') + setTimeout(function () { + featureAbility.terminateSelf() + .then((data) => { + console.info('[Demo] MainAbility2 terminateself succeeded: ' + data); + }).catch((error) => { + console.error('[Demo] MainAbility2 terminateself failed. Cause: ' + error); + }) + }, 3200); + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility2/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility2/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7c961fe38a2c490043b32fa4b1fdbca0e8d4b362 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/MainAbility2/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 Mainability2' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..1a1db9afd4b635520934f4bb93ff72d8c4f5b179 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service onCommand'); + let request = { + 'deviceId': '', + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'com.example.myapplication7.ServiceAbility', + 'moduleName': 'myapplication7', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service onConnect success!!!") + commonEvent.publish("service_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA sevice onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA sevice onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service onDisconnect success!!!") + commonEvent.publish("service_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA sevice onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service onFailed!!!") + commonEvent.publish("service_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA sevice onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility10/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility10/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..8395c782338a78720cb23ee20436c5b892a116fe --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility10/service.ts @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service10 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service10 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service10 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service10 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service10 onCommand'); + let request = { + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'com.example.myapplication8.ServiceAbility', + 'moduleName': 'xxxxx', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service10 onConnect success!!!") + commonEvent.publish("service10_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service10 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service10 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service10 onDisconnect success!!!") + commonEvent.publish("service10_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service10 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service10 onFailed!!!") + commonEvent.publish("service10_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service10 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service10 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service10 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service10 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service10 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility11/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility11/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..aa6876d1d56e64c1989e5470207c275cd387e8f5 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility11/service.ts @@ -0,0 +1,96 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service11 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service11 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service11 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service11 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service11 onCommand'); + let request = { + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'com.example.myapplication8.ServiceAbility', + 'moduleName': 'myapplication8', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + 'parameters': { + "key1": "value1", "key2": "nice to meet you", "key3": "Every ending is a new beginning!" + } + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service11 onConnect success!!!") + commonEvent.publish("service11_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service11 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service11 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service11 onDisconnect success!!!") + commonEvent.publish("service11_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service11 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service11 onFailed!!!") + commonEvent.publish("service11_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service11 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service11 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service11 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service11 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service11 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility2/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility2/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a4e9290b78dd45ee75f9e60cfbbad9938d43a98 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility2/service.ts @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service2 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service2 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service2 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service2 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service2 onCommand'); + let request = { + 'deviceId': '', + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'com.example.myapplication9.ServiceAbility', + 'moduleName': 'myapplication9', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service2 onConnect success!!!") + commonEvent.publish("service2_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA sevice onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA sevice onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service2 onDisconnect success!!!") + commonEvent.publish("service2_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA sevice onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service2 onFailed!!!") + commonEvent.publish("service2_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA sevice onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service2 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service2 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service2 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service2 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility3/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility3/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..162a94ff25e0c68ef180851bd2a832f9ddffdb8e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility3/service.ts @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service3 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service3 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service3 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service3 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service3 onCommand'); + let request = { + 'bundleName': 'com.example.different.hmservice', + 'abilityName': 'com.example.different.ServiceAbility', + 'moduleName': 'entry', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service3 onConnect success!!!") + commonEvent.publish("service3_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service3 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service3 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service3 onDisconnect success!!!") + commonEvent.publish("service3_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service3 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service3 onFailed!!!") + commonEvent.publish("service3_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service3 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service3 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service3 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service3 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service3 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility4/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility4/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..494284b14d7329bf8ca8272c89ebeb3ab99a4768 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility4/service.ts @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2022 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 particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service4 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service4 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service4 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service4 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service4 onCommand'); + let request = { + 'bundleName': 'com.example.different.hmservice', + 'abilityName': 'com.example.different.ServiceAbility', + 'moduleName': 'entry', + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service4 onConnect success!!!") + commonEvent.publish("service4_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service4 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service4 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service4 onDisconnect success!!!") + commonEvent.publish("service4_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service4 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service4 onFailed!!!") + commonEvent.publish("service4_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service4 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service4 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service4 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service4 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service4 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility5/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility5/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..476e6341c528506ce06f9c787b767fd1ff8e115f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility5/service.ts @@ -0,0 +1,91 @@ +/** + * Copyright (c) 2022 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 particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service5 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service5 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service5 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service5 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service5 onCommand'); + let request = { + 'bundleName': 'com.example.different.hmservice', + 'abilityName': 'com.example.different.ServiceAbility', + 'moduleName': 'entry', + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service5 onConnect success!!!") + commonEvent.publish("service5_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service5 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service5 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service5 onDisconnect success!!!") + commonEvent.publish("service5_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service5 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service5 onFailed!!!") + commonEvent.publish("service5_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service5 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service5 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service5 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service5 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service5 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility6/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility6/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..df7b529b9da229ccb138c3907d9fc8fea6207a19 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility6/service.ts @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service6 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service6 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service6 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service6 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service6 onCommand'); + let request = { + 'deviceId': 'XXXXX', + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'com.example.myapplication8.ServiceAbility', + 'moduleName': 'myapplication8', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service6 onConnect success!!!") + commonEvent.publish("service6_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service6 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service6 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service6 onDisconnect success!!!") + commonEvent.publish("service6_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service6 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service6 onFailed!!!") + commonEvent.publish("service6_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service6 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service6 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service6 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service6 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service6 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility7/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility7/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..fae0739015ddb0c25a614c794c428c4c8815798c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility7/service.ts @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service7 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service7 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service7 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service7 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service7 onCommand'); + let request = { + 'bundleName': 'com.example.xxx.hmservice', + 'abilityName': 'com.example.myapplication8.ServiceAbility', + 'moduleName': 'myapplication8', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service7 onConnect success!!!") + commonEvent.publish("service7_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service7 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service7 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service7 onDisconnect success!!!") + commonEvent.publish("service7_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service7 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service7 onFailed!!!") + commonEvent.publish("service7_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service7 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service7 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service7 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service7 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service7 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility8/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility8/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..a9cc5ca2bf55605b30e76457bdc162b14062e93a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility8/service.ts @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service8 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service8 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service8 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service8 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service8 onCommand'); + let request = { + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': '', + 'moduleName': 'myapplication8', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service8 onConnect success!!!") + commonEvent.publish("service8_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service8 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service8 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service8 onDisconnect success!!!") + commonEvent.publish("service8_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service8 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service8 onFailed!!!") + commonEvent.publish("service8_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service8 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service8 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service8 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service8 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service8 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility9/service.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility9/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..7980cd495a93481066e94c5af3d42513bc268abc --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/ServiceAbility9/service.ts @@ -0,0 +1,93 @@ +/** + * Copyright (c) 2022 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 wantConstant from '@ohos.ability.wantConstant'; +import particleAbility from '@ohos.ability.particleAbility'; +import rpc from '@ohos.rpc'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("FreeInstall_FA_ConnectAbility_PA service9 publish failed " + JSON.stringify(err)); + } else { + console.info("FreeInstall_FA_ConnectAbility_PA service9 publish success!!!"); + } +} + +export default { + onStart() { + console.info('FreeInstall_FA_ConnectAbility_PA service9 onStart'); + }, + onStop() { + console.info('FreeInstall_FA_ConnectAbility_PA service9 onStop'); + }, + onCommand(want, startId) { + console.info('FreeInstall_FA_ConnectAbility_PA service9 onCommand'); + let request = { + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'com.example.myapplication8.ServiceAbility', + 'moduleName': 'myapplication8', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service9 onConnect success!!!") + commonEvent.publish("service9_event", publishConnectOptions, PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service9 onConnect element : ' + JSON.stringify(element)); + console.info('FreeInstall_FA_ConnectAbility_PA service9 onConnect proxy : ' + JSON.stringify(proxy)); + if (proxy == null) { + console.error("freeInstall_featureAbility_connectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + }, + onDisconnect: async function (element1: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service9 onDisconnect success!!!") + commonEvent.publish("service9_event",publishDisconnectOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service9 onDisconnect ele : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info("FreeInstall_FA_ConnectAbility_PA service9 onFailed!!!") + commonEvent.publish("service9_event",publishFailedOptions,PublishCallBack); + console.info('FreeInstall_FA_ConnectAbility_PA service9 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('FreeInstall_FA_ConnectAbility_PA service9 connect start '); + var connection = particleAbility.connectAbility(request, options); + console.info('FreeInstall_FA_ConnectAbility_PA service9 request is:' + JSON.stringify(request)); + console.info('FreeInstall_FA_ConnectAbility_PA service9 options is:' + JSON.stringify(options)); + console.info('FreeInstall_FA_ConnectAbility_PA service9 connection=: ' + connection); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..3134bf3aca18a39ba3111efebcfe082ca2343dfe --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; +// var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility' + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) +// var cmd = 'aa start -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + var cmd = 'aa start -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0b3b77bdd087afdb5733bd99b13fbec49582c18d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,68 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "MainAbility2_desc", + "value": "description" + }, + { + "name": "MainAbility2_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility2_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility3_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility4_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility5_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility6_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility7_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility8_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility9_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility10_desc", + "value": "hap sample empty service" + }, + { + "name": "ServiceAbility11_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilityfatest/freeinstallconnectabilityfatest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..75ee65f3fd00f17fd920d4776c088d701b059938 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication0") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication0_js_assets", + ":connectstagemyapplication0_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication0" +} + +ohos_app_scope("connectstagemyapplication0_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication0_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication0_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication0_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..03faaa0be0e9f07a4357a13d3364a532097aaff5 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp0 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp0 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility myapp0 onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility myapp0 onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility myapp0 onConnect'); + console.info('ConnectAbilityTest connect myapp0 Servcie success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp0 onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp0 onReconnect'); + } + onDestroy() { + console.info('ServiceAbility myapp0 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f3fc266d0d500984fabc686d7cfc2e8822ba92a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp0' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..1a3c2e9173298878d9b23c8d7f8513008841980d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b33227ebf7d960033fcbb36fb2ed5561de481164 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication0/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1e364e8290854d41acdaf2c8b4e5da15529ecfd3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication1") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication1_js_assets", + ":connectstagemyapplication1_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication1" +} + +ohos_app_scope("connectstagemyapplication1_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication1_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication1_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication1_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/ServiceAbility_feature/ServiceAbility_feature.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/ServiceAbility_feature/ServiceAbility_feature.ts new file mode 100644 index 0000000000000000000000000000000000000000..804f965bb178e90e85fa8eadd68e882908605756 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/ServiceAbility_feature/ServiceAbility_feature.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility feature onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility feature op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility_feature extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility feature onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility feature onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility feature onConnect'); + console.info('ConnectAbilityTest connect myapp1 Servcie_feature success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility feature onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility feature onReconnect'); + } + onDestroy() { + console.info('ServiceAbility feature onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ada8c9177f629fdda43e5a1ecff2acb9fa0fd937 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp1' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..8b9c287be9a857cd7cd1087b3a8b54f85ede0bca --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication1", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication1_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility_myapp1", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility_feature", + "srcEntrance": "./ets/ServiceAbility_feature/ServiceAbility_feature.ts", + "label": "$string:form_ServiceAbility_feature_label", + "description": "$string:form_ServiceAbility_feature_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..97597539570eca059b2b9a931819fe61437cd016 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication1_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_feature_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_feature_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication1/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..1a04d8c1d6bb062c652524cc2f2daa860b826f89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication2") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication2_js_assets", + ":connectstagemyapplication2_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication2" +} + +ohos_app_scope("connectstagemyapplication2_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication2_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication2_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication2_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..3b57d52c19569dc3713b7c2bb067e57ed3394ab8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.myapp2 = this.context; + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + setTimeout(function () { + globalThis.myapp2.terminateSelf() + .then((data) => { + console.info('[Demo] myapp2 terminateself succeeded: ' + data); + }).catch((error) => { + console.error('[Demo] myapp2 terminateself failed. Cause: ' + error); + }) + }, 3200); + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9e3d97fad30acc9573ed2c835f26077eae143ee7 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp2 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp2 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility myapp2 onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility myapp2 onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility myapp2 onConnect'); + console.info('ConnectAbilityTest connect myapp2 Servcie success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp2 onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp2 onReconnect'); + } + onDestroy() { + console.info('ServiceAbility myapp2 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7f010fbe82e4c98fd7421e8110c04033ecf59a42 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp2' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..fce091ee5fccedbeeb5274cd179b889ff3a61335 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication2", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication2_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility_myapp2", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility2", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ef79324a9998468c22bffa131ae3535040aa69ad --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication2_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..19cec6755cd00bb1f38857e12a80d5674b39c357 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication3") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication3_js_assets", + ":connectstagemyapplication3_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication3" +} + +ohos_app_scope("connectstagemyapplication3_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication3_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication3_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication3_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/ServiceAbility_feature/ServiceAbility_feature.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/ServiceAbility_feature/ServiceAbility_feature.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae629c302eb88065ab6fb186f6330a5b789c5687 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/ServiceAbility_feature/ServiceAbility_feature.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp3 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp3 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility_feature extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility myapp3 onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility myapp3 onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility myapp3 onConnect'); + console.info('ConnectAbilityTest connect myapp3 Servcie_feature success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp3 onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp3 onReconnect'); + } + onDestroy() { + console.info('ServiceAbility myapp3 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..affea271289c1e604493acf05b05a3578ba16ba3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp3' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..25a7ed0e2a6651ba7c28063e01ca3d750f0bb973 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication3", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication3_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility_myapp3", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility_feature", + "srcEntrance": "./ets/ServiceAbility_feature/ServiceAbility_feature.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..d3dc82fd39ec0a1a61621302fdfccb6bb9b51e75 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication3_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication3/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0473fe140ef8fa1b0727b130348d4d896f051903 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication4") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication4_js_assets", + ":connectstagemyapplication4_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication4" +} + +ohos_app_scope("connectstagemyapplication4_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication4_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication4_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication4_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..787b0869e45e9fba46f2a964f9ac61c70ed23d62 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp4 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp4 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility myapp4 onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility myapp4 onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility myapp4 onConnect'); + console.info('ConnectAbilityTest connect myapp4 Servcie success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp4 onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp4 onReconnect'); + } + onDestroy() { + console.info('ServiceAbility myapp4 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb6a4119b8674ac5f03e0a811e7c3e03640e80fe --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp4' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..cb1a0efba3f82c9b46cfe215035f6346a1d8eebd --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication4", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication4_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility_myapp4", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility4", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..08442ec182efddaf4dbba000d78271085e5ee942 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication4_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication4/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9c752d15935441933c04a1595898ba822cbb2d57 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication5") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication5_js_assets", + ":connectstagemyapplication5_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication5" +} + +ohos_app_scope("connectstagemyapplication5_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication5_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication5_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication5_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/SeriveAbility/SeriveAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/SeriveAbility/SeriveAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8fe54f2b712daa563f4c0141fb5dcc89ace1a868 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/SeriveAbility/SeriveAbility.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp5 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp5 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility myapp5 onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility myapp5 onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility myapp5 onConnect'); + console.info('ConnectAbilityTest connect myapp5 Servcie success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp5 onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp5 onReconnect'); + } + onDestroy() { + console.info('ServiceAbility myapp5 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..cda4beb8e07e4768923f0f9ca8832bdf9d6b0338 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp5' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..6f03fd45fe31968ae3335059a02807e055b44f00 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication5", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication5_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility_myapp5", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility5", + "srcEntrance": "./ets/SeriveAbility/SeriveAbility.ts", + "label": "$string:form_SeriveAbility_label", + "description": "$string:form_SeriveAbility_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..26e5740a2d895c067ddca1b889c4471b8419d6c8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication5_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_SeriveAbility_desc", + "value": "form_description" + }, + { + "name": "form_SeriveAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication5/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f2164db427b1da39da5a607a509e3b406557179a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication6") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication6_js_assets", + ":connectstagemyapplication6_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication6" +} + +ohos_app_scope("connectstagemyapplication6_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication6_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication6_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication6_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..32f6e5e8ca1c2cae575fc00db5cf0cb74947aa4b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp6 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp6 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility myapp6 onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility myapp6 onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility myapp6 onConnect'); + console.info('ConnectAbilityTest connect myapp6 Servcie success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp6 onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp6 onReconnect'); + } + onDestroy() { + console.info('ServiceAbility myapp6 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..230696d7e9ce3d410649ffc8d5e2bffd2f25471a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp6' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..c13e1b937c97b9cd294b1ce7ac6027b5235e30bf --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication6", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication6_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility6", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..556e81fbb5c56f79f8c04170249cf857660a2e0e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication6_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication6/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..33aa2f1f88e9dcbc88b99b6b4a8af69bb106f6e0 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication7") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication7_js_assets", + ":connectstagemyapplication7_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication7" +} + +ohos_app_scope("connectstagemyapplication7_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication7_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication7_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication7_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..48849a513a8971d5cfc50e9fe14bfacc5ae80e89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp7 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp7 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility myapp7 onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility myapp7 onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility myapp7 onConnect'); + console.info('ConnectAbilityTest connect myapp7 Servcie success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp7 onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp7 onReconnect'); + } + onDestroy() { + console.info('ServiceAbility myapp7 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..475e1004167ccb883a98052cdc174902e10d5079 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp7' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..67b9e978b8350ebb6c81a513711d84171d362027 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication7", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication7_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility7", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f35b2f3d5816994467ee4ee93f41d4c2acea9a1a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication7_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication7/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..e6ca8c536ae3763635c314c45de9d7cec69ddcda --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ConnectStageMyApplication8") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":connectstagemyapplication8_js_assets", + ":connectstagemyapplication8_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ConnectStageMyApplication8" +} + +ohos_app_scope("connectstagemyapplication8_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("connectstagemyapplication8_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("connectstagemyapplication8_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":connectstagemyapplication8_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9d80376d419c3551dbd1ae8a3edcc29de0306df8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from "@ohos.application.ServiceExtensionAbility" +import rpc from '@ohos.rpc'; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des) + } + + onRemoteRequest(code, data, reply, option) { + console.info('ServiceAbility myapp8 onRemoteRequest'); + if (code === 1) { + let op1 = data.readInt(); + let op2 = data.readInt(); + reply.writeInt(op1 + op2); + console.info('ServiceAbility myapp8 op1:' + op1 + ' op2:' + op2); + } + return true; + } +} +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility myapp8 onCreate'); + } + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility myapp8 onRequest'); + } + onConnect(want) { + console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility myapp8 onConnect'); + console.info('ConnectAbilityTest connect myapp8 Servcie success'); + return new StubTest("test"); + } + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp8 onDisconnect'); + } + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility myapp8 onReconnect'); + } + onDestroy() { + console.info('ServiceAbility myapp8 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..76e7f5e858ef0d5f33618356a55980c442756547 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 myapp8' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..1fdc3aa1c43acaf76c27107539cc3f0cbe0470a1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/module.json @@ -0,0 +1,47 @@ +{ + "module": { + "name": "myapplication8", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication8_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ServiceAbility6", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..7a6badcda1f185180ee656ed8063d3990e011df5 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "myapplication8_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/connectstagemyapplication8/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/app.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..4d49fd0bb6d44d08b824f1f1e2abeac84bec9758 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.myapplication.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ba39c935bd73121b8ca4b4930df3b0634cfdf96c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "connect_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/BUILD.gn b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8f9d30d2beee32125c475245eae1d38014b10493 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FreeInstallConnectAbilityStageTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":freeinstallconnectabilitystagetest_js_assets", + ":freeinstallconnectabilitystagetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FreeInstallConnectAbilityStageTest" +} + +ohos_app_scope("freeinstallconnectabilitystagetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("freeinstallconnectabilitystagetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("freeinstallconnectabilitystagetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":freeinstallconnectabilitystagetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/Test.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..0a6ab9cd2f995e2db5a19804d3b76951d87eebea --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/Test.json @@ -0,0 +1,42 @@ +{ + "description": "Configuration for freeinstallconnectabilitystagetest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.myapplication.hmservice", + "module-name": "entry", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "FreeInstallConnectAbilityStageTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "MockService.hap -> /data/test/MockService.hap", + "ConnectStageMyApplication0.hap -> /data/test/ConnectStageMyApplication0.hap", + "ConnectStageMyApplication1.hap -> /data/test/ConnectStageMyApplication1.hap", + "ConnectStageMyApplication2.hap -> /data/test/ConnectStageMyApplication2.hap", + "ConnectStageMyApplication3.hap -> /data/test/ConnectStageMyApplication3.hap", + "ConnectStageMyApplication4.hap -> /data/test/ConnectStageMyApplication4.hap", + "ConnectStageMyApplication5.hap -> /data/test/ConnectStageMyApplication5.hap", + "ConnectStageMyApplication6.hap -> /data/test/ConnectStageMyApplication6.hap", + "ConnectStageMyApplication7.hap -> /data/test/ConnectStageMyApplication7.hap", + "ConnectStageMyApplication8.hap -> /data/test/ConnectStageMyApplication8.hap", + "ConnectDifferentApplication.hap -> /data/test/ConnectDifferentApplication.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..ed2f6521259acd7b9e821a692d04f240954bd1ec --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' +import commonEvent from '@ohos.commonEvent'; + +let publishOptions = { + parameters: { + "assertData": "onconnect" + } +}; +function PublishCallBack(err) { + if (err.code) { + console.error("Testevent service publish failed " + JSON.stringify(err)); + } else { + console.info("Testevent service publish success!!!"); + } +} + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") +// commonEvent.publish("test_event",publishOptions,PublishCallBack); + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/MainAbility2/MainAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7a9b43461342bb2ee1572ae61a5e3f955fbfab7 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility2 extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.ability2 = this.context; + windowStage.setUIContent(this.context, "pages/index2", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + setTimeout(function () { + globalThis.ability2.terminateSelf() + .then((data) => { + console.info('[Demo] MainAbility2 terminateself succeeded: ' + data); + }).catch((error) => { + console.error('[Demo] MainAbility2 terminateself failed. Cause: ' + error); + }) + }, 3200); + + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..e88f22b318e080fadfb3b68f5f2410bb81ebb5a1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service publish success!!!"); + } +} + +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service onRequest'); + let request = { + 'deviceId': '', + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'ServiceAbility6', + 'moduleName': 'myapplication6', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service onConnect success!!!'); + commonEvent.publish("service_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service onDisconnect success!!!'); + commonEvent.publish("service_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service onFailed!!!'); + commonEvent.publish("service_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts new file mode 100644 index 0000000000000000000000000000000000000000..7c72d5a05412cc8d8458a804730483b474d456f2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility2/ServiceAbility2.ts @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service2 publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service2 publish success!!!"); + } +} + +export default class ServiceAbility2 extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service2 onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service2 onRequest'); + let request = { + 'bundleName': 'com.example.different.hmservice', + 'abilityName': 'com.example.different.ServiceAbility', + 'moduleName': 'entry', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service2 onConnect success!!!'); + commonEvent.publish("service2_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service2 onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service2 onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service2 onDisconnect success!!!'); + commonEvent.publish("service2_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service2 onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service2 onFailed!!!'); + commonEvent.publish("service2_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service2 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service2 request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service2 options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service2 connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service2 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility3/ServiceAbility3.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility3/ServiceAbility3.ts new file mode 100644 index 0000000000000000000000000000000000000000..018516a050e294e6d5b71ea0bf823e406ef0449f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility3/ServiceAbility3.ts @@ -0,0 +1,84 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service3 publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service3 publish success!!!"); + } +} + +export default class ServiceAbility3 extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service3 onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service3 onRequest'); + let request = { + 'bundleName': 'com.example.different.hmservice', + 'abilityName': 'com.example.different.ServiceAbility', + 'moduleName': 'entry', + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service3 onConnect success!!!'); + commonEvent.publish("service3_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service3 onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service3 onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service3 onDisconnect success!!!'); + commonEvent.publish("service3_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service3 onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service3 onFailed!!!'); + commonEvent.publish("service3_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service3 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service3 request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service3 options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service3 connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service3 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility4/ServiceAbility4.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility4/ServiceAbility4.ts new file mode 100644 index 0000000000000000000000000000000000000000..6ab25ab7a168b2e2be0a44250d2ec41679303c25 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility4/ServiceAbility4.ts @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service4 publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service4 publish success!!!"); + } +} + +export default class ServiceAbility4 extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service4 onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service4 onRequest'); + let request = { + 'deviceId': 'XXXXX', + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'ServiceAbility7', + 'moduleName': 'myapplication7', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service4 onConnect success!!!'); + commonEvent.publish("service4_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service4 onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service4 onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service4 onDisconnect success!!!'); + commonEvent.publish("service4_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service4 onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service4 onFailed!!!'); + commonEvent.publish("service4_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service4 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service4 request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service4 options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service4 connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service4 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility5/ServiceAbility5.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility5/ServiceAbility5.ts new file mode 100644 index 0000000000000000000000000000000000000000..78e1001a0ecef30cce9f35fb037dad5bb62efda0 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility5/ServiceAbility5.ts @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service5 publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service5 publish success!!!"); + } +} + +export default class ServiceAbility4 extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service5 onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service5 onRequest'); + let request = { + 'bundleName': 'com.example.xxx.hmservice', + 'abilityName': 'ServiceAbility7', + 'moduleName': 'myapplication7', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service5 onConnect success!!!'); + commonEvent.publish("service5_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service5 onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service5 onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service5 onDisconnect success!!!'); + commonEvent.publish("service5_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service5 onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service5 onFailed!!!'); + commonEvent.publish("service5_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service5 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service5 request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service5 options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service5 connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service5 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility6/ServiceAbility6.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility6/ServiceAbility6.ts new file mode 100644 index 0000000000000000000000000000000000000000..328007605de6873f0fbc00ceba1cc37b771b5dd3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility6/ServiceAbility6.ts @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service6 publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service6 publish success!!!"); + } +} + +export default class ServiceAbility4 extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service6 onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service6 onRequest'); + let request = { + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': '', + 'moduleName': 'myapplication7', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service6 onConnect success!!!'); + commonEvent.publish("service6_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service6 onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service6 onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service6 onDisconnect success!!!'); + commonEvent.publish("service6_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service6 onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service6 onFailed!!!'); + commonEvent.publish("service6_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service6 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service6 request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service6 options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service6 connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service6 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility7/ServiceAbility7.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility7/ServiceAbility7.ts new file mode 100644 index 0000000000000000000000000000000000000000..88229fa85e7527980e80cf1dc6200ffc783b66a2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility7/ServiceAbility7.ts @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service7 publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service7 publish success!!!"); + } +} + +export default class ServiceAbility4 extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service7 onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service7 onRequest'); + let request = { + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'ServiceAbility7', + 'moduleName': 'myapplication7', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + 'parameters': { + "key1": "value1", "key2": "let your heart guide you", "tag": "Every ending is a new beginning!" + } + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service7 onConnect success!!!'); + commonEvent.publish("service7_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service7 onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service7 onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service7 onDisconnect success!!!'); + commonEvent.publish("service7_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service7 onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service7 onFailed!!!'); + commonEvent.publish("service7_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service7 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service7 request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service7 options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service7 connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service7 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility8/ServiceAbility8.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility8/ServiceAbility8.ts new file mode 100644 index 0000000000000000000000000000000000000000..ee6427eab5d6a1c32c6ab2d02295768662e0d37f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility8/ServiceAbility8.ts @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service8 publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service8 publish success!!!"); + } +} + +export default class ServiceAbility4 extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service8 onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service8 onRequest'); + let request = { + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'ServiceAbility7', + 'moduleName': 'xxxxx', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service8 onConnect success!!!'); + commonEvent.publish("service8_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service8 onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service8 onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service8 onDisconnect success!!!'); + commonEvent.publish("service8_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service8 onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service8 onFailed!!!'); + commonEvent.publish("service8_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service8 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service8 request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service8 options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service8 connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service8 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility9/ServiceAbility9.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility9/ServiceAbility9.ts new file mode 100644 index 0000000000000000000000000000000000000000..83d01c29cc7e79222970b67004fe92f94886235a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/ServiceAbility9/ServiceAbility9.ts @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishConnectOptions = { + parameters: { + "assertData": "onConnect" + } +}; +var publishDisconnectOptions = { + parameters: { + "assertData": "onDisconnect" + } +}; +var publishFailedOptions = { + parameters: { + "assertData": "onFailed" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service9 publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service9 publish success!!!"); + } +} + +export default class ServiceAbility4 extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ConnectAbilityTest_Ext service9 onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ConnectAbilityTest_Ext service9 onRequest'); + let request = { + 'bundleName': 'com.example.myapplication.hmservice', + 'abilityName': 'ServiceAbility6', + 'moduleName': 'myapplication8', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + let options = { + onConnect: async function (element: any, proxy: any) { + console.info('ConnectAbilityTest_Ext service9 onConnect success!!!'); + commonEvent.publish("service9_event",publishConnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service9 onConnect element : ' + JSON.stringify(element)); + console.info('ConnectAbilityTest_Ext service9 onConnect proxy : ' + JSON.stringify(proxy)); + }, + onDisconnect: async function (element1: any) { + console.info('ConnectAbilityTest_Ext service9 onDisconnect success!!!'); + commonEvent.publish("service9_event",publishDisconnectOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service9 onDisconnect element : ' + JSON.stringify(element1)); + }, + onFailed: async function (code: any) { + console.info('ConnectAbilityTest_Ext service9 onFailed!!!'); + commonEvent.publish("service9_event",publishFailedOptions,PublishCallBack); + console.info('ConnectAbilityTest_Ext service9 onFailed errCode : ' + JSON.stringify(code)); + }, + } + console.info('ConnectAbilityTest_Ext sevice connect start '); + var connection = this.context.connectAbility(request, options); + console.info('ConnectAbilityTest_Ext service9 request is:' + JSON.stringify(request)); + console.info('ConnectAbilityTest_Ext service9 options is:' + JSON.stringify(options)); + console.info('ConnectAbilityTest_Ext service9 connection=: ' + connection); + } + onDestroy() { + console.info('ConnectAbilityTest_Ext service9 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec20fc0823ea020a5e20468f96d136147dd3a2b8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + globalThis.delegator = abilityDelegator; + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1c3a4da0ee43f97df122a059f5bff0ad6e86ae93 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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. + */ + +// @ts-nocheck +import file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import List from '../test/ListTest' +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + globalThis.abilityWant.parameters.timeout = 60000; + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + configService.setConfig(globalThis.abilityWant.parameters); + List(globalThis.abilityContext); + core.execute(); + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/pages/index2.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/pages/index2.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f7c38d7b690ce2c7ce57fbaac28a908fecfb518 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/pages/index2.ets @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2022 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 Index2 { + @State message: string = 'Hello MainAbility2' + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ConnectAbilityTest.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ConnectAbilityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..0f7d45a2d6f0afff8f9e2c15569281c1a224424a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ConnectAbilityTest.ets @@ -0,0 +1,748 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 "deccjsunit/index" +import rpc from '@ohos.rpc'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; +import abilityManager from '@ohos.application.abilityManager'; + + +export default function ConnectAbilityTest(abilityContext) { + var TAG = ""; + var Tempassert = ""; + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + describe('ConnectAbilityTest', function () { + beforeAll(async function (done) { + console.info("ConnectAbilityTest before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + globalThis.delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + globalThis.delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("ConnectAbilityTest after each called"); + Tempassert = "" + await sleep(1000); + done(); + }); + + function tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } + + async function connectabillity(msg, request) { + console.info(msg + "START"); + let options = { + onConnect: function (element, proxy) { + console.info("FreeInstall_Stage_ConnectAbility onConnect success!!!") + console.info(msg + " onConnect success!!! "); + console.info(msg + " onConnect: " + JSON.stringify(element)); + console.info(msg + " onConnect: " + JSON.stringify(proxy)); + if (proxy == null) { + console.error("FreeInstall_Stage_ConnectAbility proxy null"); + return; + } + let option = new rpc.MessageOption(); + let data = new rpc.MessageParcel(); + let reply = new rpc.MessageParcel(); + data.writeInterfaceToken("ohos.appexecfwk.IApplicationStateObserver"); + proxy.sendRequest(0, data, reply, option); + Tempassert = "onConnect"; + tips("连接成功"); + }, + onDisconnect: function (element) { + console.info("FreeInstall_Stage_ConnectAbility onDisconnect success!!!") + console.info(msg + " onDisconnect success!!!"); + console.info(msg + " onDisconnect: " + JSON.stringify(element)); + Tempassert = "onDisconnect"; + tips("连接断开"); + }, + onFailed: function (code) { + console.info("FreeInstall_Stage_ConnectAbility onFailed!!!") + console.info(msg + " onFailed!!! "); + console.info(msg + " onFailed: " + JSON.stringify(code)); + Tempassert = "onFailed"; + tips("连接失败"); + } + } + let connection = await globalThis.abilityContext.connectAbility(request, options); + console.info(msg + "request:" + JSON.stringify(request)); + console.info(msg + "options:" + JSON.stringify(options)); + console.info(msg + "connection=" + JSON.stringify(connection)); + console.info(msg + "END"); + } + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0100 + * @tc.name Pass in the local deviceid,atomic service does not exist locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_0100", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0100-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0100"; + var cmd4 = "cp data/test/ConnectStageMyApplication0.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var deviceid = "0"; + abilityManager.getTopAbility((err, data) => { + console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err)); + console.log(TAG + 'getTopAbility result deviceid:' + JSON.stringify(data.ability.deviceId)); + deviceid = data.ability.deviceId; + }) + await sleep(500); + var request1 = { + "deviceId": deviceid, + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility", + "moduleName": "myapplication", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request1); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0100-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0200 + * @tc.name Pass in the local deviceid,atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_0200", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0200-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0200"; + var deviceid = "0"; + abilityManager.getTopAbility((err, data) => { + console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err)); + console.log(TAG + 'getTopAbility result deviceid:' + JSON.stringify(data.ability.deviceId)); + deviceid = data.ability.deviceId; + }) + await sleep(500); + var request2 = { + "deviceId": deviceid, + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility", + "moduleName": "myapplication", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request2); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0200-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0300 + * @tc.name Deviceid is empty,atomic service does not exist locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_0300", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0300-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0300"; + var cmd3 = "cp data/test/ConnectStageMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var request3 = { + "deviceId": "", + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility_feature", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request3); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0300-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0400 + * @tc.name Deviceid is empty,atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_0400", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0400-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0400"; + var request4 = { + "deviceId": "", + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility_feature", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request4); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0400-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0500 + * @tc.name The bundleName passed in is different from the local + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_0500", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0500-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0500"; + var request5 = { + "bundleName": "com.example.different.hmservice", + "abilityName": "com.example.different.ServiceAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request5); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0500-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0600 + * @tc.name Pass in an empty bundleName + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_0600", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0600-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0600"; + var request6 = { + "bundleName": "", + "abilityName": "ServiceAbility_feature", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request6); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0600-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0700 + * @tc.name Pass in an empty abilityName + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_0700", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0700-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0700"; + var request7 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request7); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0700-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0800 + * @tc.name Incorrect deviceid passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_0800", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0800-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0800"; + var request8 = { + "deviceId": "xxxxxx", + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility2", + "moduleName": "myapplication2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request8); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0800-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_0900 + * @tc.name Incorrect bundleName passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_0900", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_0900-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_0900"; + var request9 = { + "bundleName": "com.example.xxx.hmservice", + "abilityName": "ServiceAbility2", + "moduleName": "myapplication2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request9); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_0900-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1000 + * @tc.name Incorrect flags passed in,atomic service does not exist locally + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_1000", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1000-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1000"; + var request10 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility2", + "moduleName": "myapplication2", + "flags": 1111111, + } + connectabillity(TAG, request10); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1000-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1100 + * @tc.name Incorrect flags passed in,atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_1100", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1100-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1100"; + var cmdapp2 = "bm install -p data/test/ConnectStageMyApplication2.hap"; + globalThis.delegator.executeShellCommand(cmdapp2, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var request11 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility2", + "moduleName": "myapplication2", + "flags": "11", + } + connectabillity(TAG, request11); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1000-------------"); + done(); + }, 3000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1200 + * @tc.name No atomic service under path + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_1200", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1200-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1200"; + var cmdrm = "rm -r /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/*"; + globalThis.delegator.executeShellCommand(cmdrm, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var request12 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility3", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request12); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1200-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1300 + * @tc.name The application is not in the foreground [start MainAbility2 first, then connect] + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_1300", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1300-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1300"; + var str = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.MainAbility2", + } + console.info(TAG + " startmainability2 str: " + JSON.stringify(str)); + globalThis.abilityContext.startAbility(str) + .then((data) => { + console.info(TAG + " startmainability2 successful. Data: " + JSON.stringify(data)) + }).catch((error) => { + console.error(TAG + " startmainability2 failed. Cause: " + JSON.stringify(error)); + }) + await sleep(1500); + var request13 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility3", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request13); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1300-------------"); + done(); + }, 1500); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1400 + * @tc.name The application is not in the foreground [start myapp2 first, then connect] + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_1400", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1400-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1400"; + var str = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "MainAbility_myapp2", + } + console.info(TAG + " startmyapp2 str: " + JSON.stringify(str)); + globalThis.abilityContext.startAbility(str) + .then((data) => { + console.info(TAG + " startmyapp2 successful. Data: " + JSON.stringify(data)) + }).catch((error) => { + console.error(TAG + " startmyapp2 failed. Cause: " + JSON.stringify(error)); + }) + await sleep(1500); + var request14 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility3", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request14); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1400-------------"); + done(); + }, 1500); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1500 + * @tc.name The application is not in the foreground, + [start another project first, then connect,atomic service does not exist locally] + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_1500", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1500-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1500"; + var cmddif = "bm install -p data/test/ConnectDifferentApplication.hap"; + globalThis.delegator.executeShellCommand(cmddif, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var str = { + "bundleName": "com.example.different.hmservice", + "abilityName": "MainAbility", + }; + globalThis.abilityContext.startAbility(str) + .then((data) => { + console.info(TAG + " startother successful. Data: " + JSON.stringify(data)) + }).catch((error) => { + console.error(TAG + " startother failed. Cause: " + JSON.stringify(error)); + }) + await sleep(1500); + var request15 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility4", + "moduleName": "myapplication4", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request15); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1500-------------"); + done(); + }, 1500); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1600 + * @tc.name The application is not in the foreground, + [start another project first, then connect,atomic service exists locally] + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_1600", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1600-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1600"; + var cmdmyapp4 = "bm install -p data/test/ConnectStageMyApplication4.hap"; + globalThis.delegator.executeShellCommand(cmdmyapp4, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var str = { + "bundleName": "com.example.different.hmservice", + "abilityName": "MainAbility", + }; + globalThis.abilityContext.startAbility(str) + .then((data) => { + console.info(TAG + " startother successful. Data: " + JSON.stringify(data)) + }).catch((error) => { + console.error(TAG + " startother failed. Cause: " + JSON.stringify(error)); + }) + await sleep(1500); + var request16 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility4", + "moduleName": "myapplication4", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request16); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1600-------------"); + done(); + }, 1500); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1700 + * @tc.name Do not pass flags, connect to the service of another project + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_1700", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1700-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1700"; + var request17 = { + "bundleName": "com.example.different.hmservice", + "abilityName": "com.example.different.ServiceAbility", + "moduleName": "entry", + } + connectabillity(TAG, request17); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1700-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1800 + * @tc.name Incorrect moduleName passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_1800", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1800-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1800"; + var request18 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility3", + "moduleName": "xxxxx", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request18); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1800-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_1900 + * @tc.name The target is atomized as hapA, and hapB is placed under the path + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_1900", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_1900-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_1900"; + var cmdmyapp5 = "cp data/test/ConnectStageMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var request19 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility3", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request19); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_1900-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_2000 + * @tc.name Pass in parameters + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_2000", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_2000-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_2000"; + var cmdmyapp5 = "cp data/test/ConnectStageMyApplication5.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var request20 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility5", + "moduleName": "myapplication5", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + "parameters": { "name": 1111, "key1": "value1", "site": "nice to meet you!" }, + } + connectabillity(TAG, request20); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_2000-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_2100 + * @tc.name The atomic service of the target differs only by moduleName + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_2100", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_2100-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_2100"; + var cmdmyapp5 = "cp data/test/ConnectStageMyApplication3.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmdmyapp5, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var request21 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility_feature", + "moduleName": "myapplication3", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request21); + setTimeout(function () { + expect(Tempassert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_2100-------------"); + done(); + }, 2000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_2200 + * @tc.name The application is not in the foreground, + [the current application is in the background first,then connect] + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_2200", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_2200-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_2200"; + var ability; + globalThis.delegator.getCurrentTopAbility((err : any, data : any) => { + console.info(TAG + " getCurrentTopAbility data: " + JSON.stringify(data) + " ,err: " + JSON.stringify(err)); + ability = data; + globalThis.delegator.doAbilityBackground(ability, (err : any, data : any) => { + console.info(TAG + " doAbilityBackground data: " + JSON.stringify(data) + " ,err: " + JSON.stringify(err)); + }) + }); + await sleep(1000); + var request22 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "ServiceAbility6", + "moduleName": "myapplication6", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + connectabillity(TAG, request22); + setTimeout(function () { + expect(Tempassert).assertEqual("onFailed"); + globalThis.delegator.doAbilityForeground(ability, (err : any, data : any) => { + console.info(TAG + " doAbilityForeground data: " + JSON.stringify(data) + " ,err: " + JSON.stringify(err)); + }) + console.log("------------end FreeInstall_Stage_ConnectAbility_2200-------------"); + done(); + }, 4000); + }); + } + ) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ConnectAbilityTest_Ext.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ConnectAbilityTest_Ext.ets new file mode 100644 index 0000000000000000000000000000000000000000..fdcda47764b58703e9153d24752b76187b8bfe71 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ConnectAbilityTest_Ext.ets @@ -0,0 +1,433 @@ +// @ts-nocheck +/** + * Copyright (c) 2022 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 "deccjsunit/index" +import commonEvent from '@ohos.commonEvent'; + +export default function ConnectAbilityTest_Ext(abilityContext) { + var TAG = ""; + var dataAssert = ""; + var subscriber; + var subscribeInfo = { + events: ["service_event", "service2_event", "service3_event", + "service4_event", "service5_event", "service6_event", + "service7_event", "service8_event", "service9_event"] + }; + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + async function startService(msg, str) { + console.info(msg + ' startService successful. str: ' + JSON.stringify(str)); + globalThis.abilityContext.startAbility(str) + .then((data) => { + console.info(msg + ' startService successful. Data: ' + JSON.stringify(data)); + }).catch((error) => { + console.error(msg + ' startService failed. Cause: ' + JSON.stringify(error)); + }) + } + + function checkParameters(msg1, data) { + for (var key in data.parameters) { + console.info(msg1 + " data.parameters is : " + data.parameters[key]) + if (data.parameters[key] === "onFailed") { + dataAssert = "onFailed"; + } else if (data.parameters[key] === "onDisconnect") { + dataAssert = "onDisconnect"; + } else if (data.parameters[key] === "onConnect") { + dataAssert = "onConnect"; + } + } + } + + function SubscribeCallBack(err, data) { + if (err.code) { + console.error("commonEvent subscribe failed " + JSON.stringify(err)); + } else { + if (data.event === "service_event") { + console.info("commonEvent subscribe service " + JSON.stringify(data)); + checkParameters("commonEvent service", data) + } else if (data.event === "service2_event") { + console.info("commonEvent subscribe service2 " + JSON.stringify(data)); + checkParameters("commonEvent service2", data) + } else if (data.event === "service3_event") { + console.info("commonEvent subscribe service3 " + JSON.stringify(data)); + checkParameters("commonEvent service3", data) + } else if (data.event === "service4_event") { + console.info("commonEvent subscribe service4 " + JSON.stringify(data)); + checkParameters("commonEvent service4", data) + } else if (data.event === "service5_event") { + console.info("commonEvent subscribe service5 " + JSON.stringify(data)); + checkParameters("commonEvent service5", data) + } else if (data.event === "service6_event") { + console.info("commonEvent subscribe service6 " + JSON.stringify(data)); + checkParameters("commonEvent service6", data) + } else if (data.event === "service7_event") { + console.info("commonEvent subscribe service7 " + JSON.stringify(data)); + checkParameters("commonEvent service7", data) + } else if (data.event === "service8_event") { + console.info("commonEvent subscribe service8 " + JSON.stringify(data)); + checkParameters("commonEvent service8", data) + } else if (data.event === "service9_event") { + console.info("commonEvent subscribe service9 " + JSON.stringify(data)); + checkParameters("commonEvent service9", data) + } + } + } + + function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("commonEvent createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("----commonEvent createSubscriber------"); + subscriber = commonEventSubscriber; + commonEvent.subscribe(subscriber, SubscribeCallBack); + } + } + + describe('FreeInstall_Stage_ConnectAbility_Ext', function () { + beforeAll(async function (done) { + console.info("FreeInstall_Stage_ConnectAbility_Ext before all called"); + console.info("FreeInstall_Stage_ConnectAbility_Ext commonEvent.createSubscriber start!!!"); + commonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); + await sleep(2000); + var cmd = "bm install -p data/test/Mockservice.hap"; + console.info("cmd : " + cmd) + globalThis.delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + globalThis.delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("FreeInstall_Stage_ConnectAbility_Ext after each called"); + dataAssert = "" + await sleep(1000); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0100 + * @tc.name Deviceid is empty,atomic service does not exist locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0100", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0100-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0100"; + var cmdmyapp6 = "cp data/test/ConnectStageMyApplication6.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmdmyapp6, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var str1 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility", + }; + startService(TAG, str1); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0100-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0200 + * @tc.name Deviceid is empty,atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0200", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0200-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0200"; + var str1 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility", + }; + startService(TAG, str1); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0200-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0300 + * @tc.name The bundleName passed in is different from the local + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0300", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0300-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0300"; + var cmdum = "bm uninstall -n com.example.different.hmservice"; + globalThis.delegator.executeShellCommand(cmdum, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var str2 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility2", + }; + startService(TAG, str2); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0300-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0400 + * @tc.name Do not pass flags, atomic service does not exist locally + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0400", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0400-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0400"; + var str3 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility3", + }; + startService(TAG, str3); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0400-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0500 + * @tc.name Do not pass flags, atomic service exists locally + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0500", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0500-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0500"; + var cmdin = "bm install -p data/test/ConnectDifferentApplication.hap"; + globalThis.delegator.executeShellCommand(cmdin, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var str3 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility3", + }; + startService(TAG, str3); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0500-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0600 + * @tc.name Incorrect deviceid passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0600", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0600-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0600"; + var str4 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility4", + }; + startService(TAG, str4); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0600-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0700 + * @tc.name Incorrect bundleName passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0700", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0700-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0700"; + var str5 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility5", + }; + startService(TAG, str5); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0700-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0800 + * @tc.name Pass in an empty abilityName + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0800", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0800-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0800"; + var str6 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility6", + }; + startService(TAG, str6); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0800-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_0900 + * @tc.name No atomic service under path + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_0900", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_0900-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_0900"; + var cmdrm = "rm -r /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/*"; + globalThis.delegator.executeShellCommand(cmdrm, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var str7 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility7", + }; + startService(TAG, str7); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_0900-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_1000 + * @tc.name Incorrect moduleName passed in + * @tc.desc Function test + * @tc.level 1 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_1000", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_1000-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_1000"; + var str8 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility8", + }; + startService(TAG, str8); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onFailed"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_1000-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_1100 + * @tc.name Pass in parameters + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_1100", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_1100-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_1100"; + var cmdmyapp7 = "cp data/test/ConnectStageMyApplication7.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmdmyapp7, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var str7 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility7", + }; + startService(TAG, str7); + setTimeout(function () { + + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_1100-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_Stage_ConnectAbility_Ext_1200 + * @tc.name The atomic service of the target differs only by moduleName + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_ConnectAbility_Ext_1200", 0, async function (done) { + console.log("------------start FreeInstall_Stage_ConnectAbility_Ext_1200-------------"); + TAG = "FreeInstall_Stage_ConnectAbility_Ext_1200"; + var cmdmyapp8 = "cp data/test/ConnectStageMyApplication8.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmdmyapp8, (err: any, d: any) => { + console.info(TAG + " executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(1000); + var str9 = { + "bundleName": "com.example.myapplication.hmservice", + "abilityName": "com.example.myapplication.ServiceAbility9", + }; + startService(TAG, str9); + setTimeout(function () { + console.info(TAG + " SubscribeCallBack data: " + JSON.stringify(dataAssert)); + expect(dataAssert).assertEqual("onConnect"); + console.log("------------end FreeInstall_Stage_ConnectAbility_Ext_1200-------------"); + done(); + }, 4000); + }); + } + ) +} + diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ListTest.ets b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ListTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..16cdee817a3fb77325df1eeb9de4fe28babac76a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/ets/test/ListTest.ets @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2022 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 ConnectAbilityTest from './ConnectAbilityTest' +import ConnectAbilityTest_Ext from './ConnectAbilityTest_Ext' + +export default function List(context) { + ConnectAbilityTest(context) + ConnectAbilityTest_Ext(context) + +} + diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..47f0bca2d9956d38a116df21d565011472d37045 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/module.json @@ -0,0 +1,133 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.myapplication.hmservice.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "orientation": "portrait", + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "com.example.myapplication.MainAbility2", + "srcEntrance": "./ets/MainAbility2/MainAbility2.ts", + "description": "$string:MainAbility2_desc", + "icon": "$media:icon", + "label": "$string:MainAbility2_label" + } + ], + "extensionAbilities": [ + { + "name": "com.example.myapplication.ServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service" + }, + { + "name": "com.example.myapplication.ServiceAbility2", + "srcEntrance": "./ets/ServiceAbility2/ServiceAbility2.ts", + "label": "$string:form_ServiceAbility2_label", + "description": "$string:form_ServiceAbility2_desc", + "type": "service" + }, + { + "name": "com.example.myapplication.ServiceAbility3", + "srcEntrance": "./ets/ServiceAbility3/ServiceAbility3.ts", + "label": "$string:form_ServiceAbility3_label", + "description": "$string:form_ServiceAbility3_desc", + "type": "service" + }, + { + "name": "com.example.myapplication.ServiceAbility4", + "srcEntrance": "./ets/ServiceAbility4/ServiceAbility4.ts", + "label": "$string:form_ServiceAbility4_label", + "description": "$string:form_ServiceAbility4_desc", + "type": "service" + }, + { + "name": "com.example.myapplication.ServiceAbility5", + "srcEntrance": "./ets/ServiceAbility5/ServiceAbility5.ts", + "label": "$string:form_ServiceAbility5_label", + "description": "$string:form_ServiceAbility5_desc", + "type": "service" + }, + { + "name": "com.example.myapplication.ServiceAbility6", + "srcEntrance": "./ets/ServiceAbility6/ServiceAbility6.ts", + "label": "$string:form_ServiceAbility6_label", + "description": "$string:form_ServiceAbility6_desc", + "type": "service" + }, + { + "name": "com.example.myapplication.ServiceAbility7", + "srcEntrance": "./ets/ServiceAbility7/ServiceAbility7.ts", + "label": "$string:form_ServiceAbility7_label", + "description": "$string:form_ServiceAbility7_desc", + "type": "service" + }, + { + "name": "com.example.myapplication.ServiceAbility8", + "srcEntrance": "./ets/ServiceAbility8/ServiceAbility8.ts", + "label": "$string:form_ServiceAbility8_label", + "description": "$string:form_ServiceAbility8_desc", + "type": "service" + }, + { + "name": "com.example.myapplication.ServiceAbility9", + "srcEntrance": "./ets/ServiceAbility9/ServiceAbility9.ts", + "label": "$string:form_ServiceAbility9_label", + "description": "$string:form_ServiceAbility9_desc", + "type": "service" + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.MANAGE_MISSIONS" + }, + { + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.REMOVE_CACHE_FILES" + }, + { + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4f0ccddf1080aa6c827371305a49b0fb69d1461b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,96 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "MainAbility2_desc", + "value": "description" + }, + { + "name": "MainAbility2_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility2_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility2_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility3_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility3_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility4_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility4_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility5_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility5_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility6_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility6_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility7_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility7_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility8_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility8_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility9_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility9_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..cf165f79684f747143d39db9288641c423b2e0fe --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index", + "pages/index2" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/connectabilitystagetest/freeinstallconnectabilitystagetest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/mockservice/AppScope/app.json b/ability/ability_runtime/freeinstalltest/mockservice/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..8308d9c80802f5efb10dcf0db98198a72d9fc6b3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.ohos.hag.famanager", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservice/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/mockservice/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f299deda5858e1fac8d79b0f7573fcf9a7e525c3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Mockservice" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/mockservice/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/mockservice/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/mockservice/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/mockservice/BUILD.gn b/ability/ability_runtime/freeinstalltest/mockservice/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..d416ecee0269e7c37ffa7f380dbfe98122bb9644 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("MockService") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":mockservice_js_assets", + ":mockservice_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "MockService" +} + +ohos_app_scope("mockservice_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("mockservice_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("mockservice_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":mockservice_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/mockservice/Test.json b/ability/ability_runtime/freeinstalltest/mockservice/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..9736035f665c8530d0b432df3d015260e03368c0 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..8517eaed4819c22e6de51fcae9665b1768c24f9a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,490 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import rpc from '@ohos.rpc' +import bundle from "@ohos.bundle"; + +var result = { + transactId: "-1", + resultMsg: "", + retCode: 0 // 0表示FA服务端执行成功 +} + +var progress = { + downloadSize: 0, + totalSize: 0 +} + +// FA服务中心需要传递给BMS的json字符串的原始对象 +var installResult = { + version: "1", + result: result, + progress: progress +} + +var targetbundleName = ""; +var targetabilityName = ""; +var targetmoduleName = ""; +var path = ["/data/storage/el2/base/haps/entry/files/"]; +var exterrcode = 0; +var sendcode; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des); + } + + onRemoteRequest(code: any, data: any, reply: any, option: any) { + console.info('ServiceAbility serviceCenter onRemoteRequest START'); + //获取BMS传递的Token + let interfaceToken = data.readInterfaceToken(); + console.info("ServiceAbility serviceCenter sendRequest interfaceToken = " + interfaceToken); + // 获取BMS传递的参数 -- json字符串 + let op1 = data.readString(); + console.info("ServiceAbility serviceCenter sendRequest op1 = " + op1); + let targetAbilityInfo = JSON.parse(op1); + // 解析出BMS传递的transactId + let transactId = targetAbilityInfo.targetInfo.transactId; + console.info("ServiceAbility serviceCenter sendRequest targetAbilityInfo->targetInfo->transactId = " + + transactId); + // 解析出BMS传递的bundleName + targetbundleName = targetAbilityInfo.targetInfo.bundleName; + console.info("ServiceAbility serviceCenter sendRequest targetAbilityInfo->targetInfo->bundleName = " + + targetbundleName); + // 解析出BMS传递的abilityName + targetabilityName = targetAbilityInfo.targetInfo.abilityName; + console.info("ServiceAbility serviceCenter sendRequest targetAbilityInfo->targetInfo->abilityName = " + + targetabilityName); + // 解析出BMS传递的moduleName + targetmoduleName = targetAbilityInfo.targetInfo.moduleName; + console.info("ServiceAbility serviceCenter sendRequest targetAbilityInfo->targetInfo->moduleName = " + + targetmoduleName); + + // 解析出BMS传递的扩展信息的错误码 + let targeterrcode = targetAbilityInfo.targetExtSetting.extInfo.Servicecenter_error_code; + console.info("ServiceAbility serviceCenter targetAbilityInfo->targetExtSetting->extInfo->" + + "Servicecenter_error_code = " + targeterrcode); + if (targeterrcode === undefined) { + exterrcode = 0; + console.info("ServiceAbility serviceCenter exterrcode = " + exterrcode); + } else { + exterrcode = parseInt(targeterrcode); + console.info("ServiceAbility serviceCenter exterrcode = " + exterrcode); + } + + // 获取BSM传递的callback对象 + let op2 = data.readRemoteObject(); + console.info("ServiceAbility serviceCenter sendRequest op2 = " + op2); + + console.info("ServiceAbility serviceCenter sendRequest code = " + code); + + if (code == 2 || code == 4 ) { // 2为免安装 3为检查更新 4为安装 + targetInfoCheck(transactId, op2) + } else if (code == 3) { + serviceCheckUpdate(transactId, op2); + } +// else if (code == 4) { +// updateInfoCheck(transactId, op2); +// } + return true; + } +} + +async function targetInfoCheck(transactId: string, remoteObj: any) { + if (exterrcode != 0) { + console.info("ServiceAbility serviceCenter targetInfoCheck exterrcode = " + exterrcode); + let retcode = exterrcode; + console.info("ServiceAbility serviceCenter targetInfoCheck retcode = " + retcode); + sendCallBack(transactId, remoteObj, retcode); + } + else if ( (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication6.ServiceAbility" && targetmoduleName === "myapplication6" + )) { + path = ["/data/storage/el2/base/haps/entry/files/ConnectFaMyApplication6.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication1.ServiceAbility_feature" && targetmoduleName === "myapplication1" + ) + || (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication1.MainAbility" && targetmoduleName === "myapplication1" + )) { + path = ["/data/storage/el2/base/haps/entry/files/ConnectFaMyApplication1.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication1.ServiceAbility_feature" && targetmoduleName === "myapplication3" + ) { + path = ["/data/storage/el2/base/haps/entry/files/ConnectFaMyApplication3.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication5.ServiceAbility5" && targetmoduleName === "myapplication5" + ) { + path = ["/data/storage/el2/base/haps/entry/files/ConnectFaMyApplication5.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication7.ServiceAbility" && targetmoduleName === "myapplication7" + ) { + path = ["/data/storage/el2/base/haps/entry/files/ConnectFaMyApplication7.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication8.ServiceAbility" && targetmoduleName === "myapplication8" + ) { + path = ["/data/storage/el2/base/haps/entry/files/ConnectFaMyApplication8.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication7.ServiceAbility" && targetmoduleName === "myapplication9" + ) { + path = ["/data/storage/el2/base/haps/entry/files/ConnectFaMyApplication9.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + //connect stage + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "ServiceAbility" && targetmoduleName === "myapplication" + ){ + path = ["/data/storage/el2/base/haps/entry/files/ConnectStageMyApplication0.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "ServiceAbility_feature" && targetmoduleName === "myapplication1" + ){ + path = ["/data/storage/el2/base/haps/entry/files/ConnectStageMyApplication1.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "ServiceAbility_feature" && targetmoduleName === "myapplication3" + ){ + path = ["/data/storage/el2/base/haps/entry/files/ConnectStageMyApplication3.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "ServiceAbility5" && targetmoduleName === "myapplication5" + ){ + path = ["/data/storage/el2/base/haps/entry/files/ConnectStageMyApplication5.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "ServiceAbility6" && targetmoduleName === "myapplication6" + ){ + path = ["/data/storage/el2/base/haps/entry/files/ConnectStageMyApplication6.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "ServiceAbility7" && targetmoduleName === "myapplication7" + ){ + path = ["/data/storage/el2/base/haps/entry/files/ConnectStageMyApplication7.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "ServiceAbility6" && targetmoduleName === "myapplication8" + ) ){ + path = ["/data/storage/el2/base/haps/entry/files/ConnectStageMyApplication8.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + + else if (targetbundleName === "com.ohos.atomic1.hmservice" && + targetabilityName === "MainAbility" + // && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/Atomic1_stage.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.ohos.atomic1.hmservice" && + targetabilityName === "com.ohos.atomic1.MainAbility" + // && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/Atomic1_FA.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.startAbilityForResult.hmservice" && + targetabilityName === "MainAbility1" && targetmoduleName === "myapplication1" + ) { + path = ["/data/storage/el2/base/haps/entry/files/StageResultMyApplication1.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.open.harmony.startAbilityForResult" && + targetabilityName === "com.example.myapplication1.MainAbility1" && targetmoduleName === "myapplication1" + ) { + path = ["/data/storage/el2/base/haps/entry/files/FaResultMyApplication1.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } else if (targetbundleName === "com.open.harmony.startAbility" && + targetabilityName === "com.example.myapplication1.MainAbility1" && targetmoduleName === "myapplication1" + ) { + path = ["/data/storage/el2/base/haps/entry/files/FaMyApplication1.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.qianyiyingyong.MainAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.qianyiyingyong.ServiceAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.qianyiyingyong.MainAbility" && targetmoduleName === "hm1" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.hm3.MainAbility" && targetmoduleName === "hm3" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.hm2.MainAbility" && targetmoduleName === "hnm2" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "hm3MainAbility" && targetmoduleName === "hm3" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "hnm2MainAbility" && targetmoduleName === "hnm2" + ) + || (targetbundleName === "com.example.myapplication.hmservice0" && + targetabilityName === "com.example.myapplication.MainAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.example.myapplication.hmservice0" && + targetabilityName === "com.example.myapplication1.MainAbility" && targetmoduleName === "myapplication1" + ) + || (targetbundleName === "com.example.myapplication.hmservice0" && + targetabilityName === "com.example.myapplication2.MainAbility" && targetmoduleName === "myapplication2" + ) + || (targetbundleName === "com.open.harmony.myapplication0.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.open.harmony.myapplication0.hmservice" && + targetabilityName === "MainAbility1" && targetmoduleName === "myapplication1" + ) + || (targetbundleName === "com.open.harmony.myapplication0.hmservice" && + targetabilityName === "MainAbility2" && targetmoduleName === "myapplication2" + ) + || (targetbundleName === "com.open.harmony.packagemag.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "myapplication1" + ) + ) { + path = ["/data/storage/el2/base/haps/entry/files"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.hm2.MainAbility" && targetmoduleName === "hm4" + ) { + path = ["/data/storage/el2/base/haps/entry/files/AtomizationFaHm4.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplicationA.hmserviceA" && + targetabilityName === "com.example.myapplicationA.MainAbility" && targetmoduleName === "entry" + ) || (targetbundleName === "com.open.harmony.myapplicationA.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry")) { + path = ["/data/storage/el2/base/haps/entry/files/AtomizationResultA.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplicationB.hmserviceB" && + targetabilityName === "com.example.myapplicationB.MainAbility" && targetmoduleName === "entry" + ) || (targetbundleName === "com.open.harmony.myapplicationB.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry")) { + path = ["/data/storage/el2/base/haps/entry/files/B.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplicationC.hmserviceC" && + targetabilityName === "com.example.myapplicationC.MainAbility" && targetmoduleName === "entry" + ) || (targetbundleName === "com.open.harmony.myapplicationC.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry")) { + path = ["/data/storage/el2/base/haps/entry/files/C.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else { + sendCallBack(transactId, remoteObj, -1); + } +} + +async function updateInfoCheck(transactId: string, remoteObj: any) { + //startAbility 高低版本 + if (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.qianyiyingyong.MainAbility" && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/sign-core-qianyi-allv2.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + //免安装更新 stage模型 + else if (targetbundleName === "com.ohos.atomic1.hmservice" && + targetabilityName === "MainAbility" + // && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/Atomic1_stage_V2.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + //免安装更新 FA模型 + else if (targetbundleName === "com.ohos.atomic1.hmservice" && + targetabilityName === "com.ohos.atomic1.MainAbility" + // && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/Atomic1_FA_V2.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + //免安装更新 同应用 Stage模型 + else if (targetbundleName === "com.ohos.myapplication.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "myapplication" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapp_stage_V2.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + + else { + sendCallBack(transactId, remoteObj, -1); + } +} + +async function serviceInstall(transactId: string, remoteObj: any) { + console.info('ServiceAbility serviceCenter install start'); + // let bundleFilePaths = ["/data/storage/el2/base/haps/entry/files/"]; + let bundleFilePaths = path; + let param = { + userId: 100, + installFlag: 16, + isKeepData: false + } + let installer = await bundle.getBundleInstaller(); + installer.install(bundleFilePaths, param, (err: any, data: any) => { + console.info('ServiceAbility serviceCenter install. Data status: ' + JSON.stringify(data.status)); + console.info('ServiceAbility serviceCenter install. Data statusMessage: ' + JSON.stringify(data.statusMessage)); + console.info('ServiceAbility serviceCenter install. bundleFilePaths:' + JSON.stringify(bundleFilePaths)); + console.info('ServiceAbility serviceCenter install. param:' + JSON.stringify(param)); + console.info('ServiceAbility serviceCenter install. Cause:' + JSON.stringify(err)); + sendcode = parseInt(err.code); + if (sendcode === -1) { + sendcode = -5; + } + console.info('ServiceAbility serviceCenter install. code:' + sendcode); + bundle.setModuleUpgradeFlag(targetbundleName, targetmoduleName, 0) + .then((data) => { + console.info('ServiceAbility serviceCenter install flag bundleName : ' + JSON.stringify(targetbundleName) + + ', moduleName : ' + JSON.stringify(targetmoduleName)); + console.info('ServiceAbility serviceCenter UpgradeFlag method, data: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('ServiceAbility serviceCenter install flag bundleName : ' + JSON.stringify(targetbundleName) + + ', moduleName : ' + JSON.stringify(targetmoduleName)); + console.error('ServiceAbility serviceCenter UpgradeFlag method, error: ' + JSON.stringify(error)); + }); + console.info("ServiceAbility serviceCenter serviceInstall callBack obj = " + remoteObj); + console.info("ServiceAbility serviceCenter serviceInstall code = " + sendcode); + sendCallBack(transactId, remoteObj, sendcode); + }); + +} + +async function serviceCheckUpdate(transactId: string, remoteObj: any) { + console.info('ServiceAbility serviceCenter serviceCheckUpdate start'); + bundle.setModuleUpgradeFlag(targetbundleName, targetmoduleName, 1) + .then((data) => { + console.info('ServiceAbility serviceCenter UpgradeFlag bundleName value: ' + JSON.stringify(targetbundleName)); + console.info('ServiceAbility serviceCenter UpgradeFlag moduleName value: ' + JSON.stringify(targetmoduleName)); + console.info('ServiceAbility serviceCenter UpgradeFlag method, data: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('ServiceAbility serviceCenter UpgradeFlag bundleName value: ' + JSON.stringify(targetbundleName)); + console.info('ServiceAbility serviceCenter UpgradeFlag moduleName value: ' + JSON.stringify(targetmoduleName)); + console.error('ServiceAbility serviceCenter UpgradeFlag method, error: ' + JSON.stringify(error)); + }); + setTimeout(function () { + console.info("ServiceAbility serviceCenter serviceCheckUpdate sendCallBack sleep 35000 !!!") + sendCallBack(transactId, remoteObj, 0); + },35000) +} + +function sendCallBack(transactId: string, remoteObj: any, code: number) { + console.info("ServiceAbility serviceCenter sendCallBack remoteObj = " + remoteObj); + let option1 = new rpc.MessageOption(); + let data1 = rpc.MessageParcel.create(); + let reply1 = rpc.MessageParcel.create(); + // 写入token + // data1.writeInterfaceToken("ohos.aafwk.IAtomicServiceStatusCallback"); + data1.writeInterfaceToken("abilitydispatcherhm.openapi.hapinstall.IHapInstallCallback"); + // 将BMS传递的transactId返回给BMS + installResult.result.transactId = transactId; + installResult.result.retCode = code; + console.info('ServiceAbility serviceCenter code:' + code); + let returnString = JSON.stringify(installResult); + console.info("ServiceAbility serviceCenter sendRequest returnString = " + returnString); + // 返回给BMS的参数 -- json字符串 + data1.writeString(returnString); + remoteObj.sendRequest(1, data1, reply1, option1, (err, result) => { + console.info("ServiceAbility serviceCenter sendRequest result:" + result + ",err:" + err); + if (err === 0) { + console.info("ServiceAbility serviceCenter sendRequest got result"); + } + }); +} + + + +export default class ServiceExtAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility serviceCenter onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility serviceCenter onRequest'); + } + + onConnect(want) { + // console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility serviceCenter onConnect'); + return new StubTest("test"); + } + + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility serviceCenter onDisconnect'); + } + + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility serviceCenter onReconnect'); + } + + onDestroy() { + console.info('ServiceAbility serviceCenter onDestroy'); + } +} diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..101a1580a2a7c95f0200a1d3a7dd4df6cd538402 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 serviceCenter' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..a004f10a8b3aca76970352096e3bb3f8f2323bdf --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/module.json @@ -0,0 +1,48 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "requestPermissions": [ {"name": "ohos.permission.INSTALL_BUNDLE"}], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "HapInstallServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service", + "visible": true, + "icon": "$media:icon" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c3d85e5418e6e92ed6134d6690b5cbec5cf80256 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "Mockservice" + }, + { + "name": "form_ServiceAbility_desc", + "value": "service" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservice/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/mockservice/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/mockservice/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/mockservice/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/app.json b/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..8308d9c80802f5efb10dcf0db98198a72d9fc6b3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.ohos.hag.famanager", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f299deda5858e1fac8d79b0f7573fcf9a7e525c3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Mockservice" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/mockservicetimeout/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/BUILD.gn b/ability/ability_runtime/freeinstalltest/mockservicetimeout/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..afa4d52c6cf942976a7824cc18b6b8cbe2124d46 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("MockServiceTimeout") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":mockservicetimeout_js_assets", + ":mockservicetimeout_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "MockServiceTimeout" +} + +ohos_app_scope("mockservicetimeout_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("mockservicetimeout_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("mockservicetimeout_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":mockservicetimeout_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/Test.json b/ability/ability_runtime/freeinstalltest/mockservicetimeout/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..9736035f665c8530d0b432df3d015260e03368c0 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..284c5fa8d153e945c6e1a840629e5b79b5ba2893 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,450 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import rpc from '@ohos.rpc' +import bundle from "@ohos.bundle"; + +var result = { + transactId: "-1", + resultMsg: "", + retCode: 0 // 0表示FA服务端执行成功 +} + +var progress = { + downloadSize: 0, + totalSize: 0 +} + +// FA服务中心需要传递给BMS的json字符串的原始对象 +var installResult = { + version: "1", + result: result, + progress: progress +} + +var targetbundleName = ""; +var targetabilityName = ""; +var targetmoduleName = ""; +var path = ["/data/storage/el2/base/haps/entry/files/"]; +var exterrcode = 0; +var sendcode; + +class StubTest extends rpc.RemoteObject { + constructor(des) { + super(des); + } + + onRemoteRequest(code: any, data: any, reply: any, option: any) { + console.info('ServiceAbility serviceCenter onRemoteRequest START'); + //获取BMS传递的Token + let interfaceToken = data.readInterfaceToken(); + console.info("ServiceAbility serviceCenter sendRequest interfaceToken = " + interfaceToken); + // 获取BMS传递的参数 -- json字符串 + let op1 = data.readString(); + console.info("ServiceAbility serviceCenter sendRequest op1 = " + op1); + let targetAbilityInfo = JSON.parse(op1); + // 解析出BMS传递的transactId + let transactId = targetAbilityInfo.targetInfo.transactId; + console.info("ServiceAbility serviceCenter sendRequest targetAbilityInfo->targetInfo->transactId = " + + transactId); + // 解析出BMS传递的bundleName + targetbundleName = targetAbilityInfo.targetInfo.bundleName; + console.info("ServiceAbility serviceCenter sendRequest targetAbilityInfo->targetInfo->bundleName = " + + targetbundleName); + // 解析出BMS传递的abilityName + targetabilityName = targetAbilityInfo.targetInfo.abilityName; + console.info("ServiceAbility serviceCenter sendRequest targetAbilityInfo->targetInfo->abilityName = " + + targetabilityName); + // 解析出BMS传递的moduleName + targetmoduleName = targetAbilityInfo.targetInfo.moduleName; + console.info("ServiceAbility serviceCenter sendRequest targetAbilityInfo->targetInfo->moduleName = " + + targetmoduleName); + + // 解析出BMS传递的扩展信息的错误码 + let targeterrcode = targetAbilityInfo.targetExtSetting.extInfo.Servicecenter_error_code; + console.info("ServiceAbility serviceCenter targetAbilityInfo->targetExtSetting->extInfo->" + + "Servicecenter_error_code = " + targeterrcode); + if (targeterrcode === undefined) { + exterrcode = 0; + console.info("ServiceAbility serviceCenter exterrcode = " + exterrcode); + } else { + exterrcode = parseInt(targeterrcode); + console.info("ServiceAbility serviceCenter exterrcode = " + exterrcode); + } + + // 获取BSM传递的callback对象 + let op2 = data.readRemoteObject(); + console.info("ServiceAbility serviceCenter sendRequest op2 = " + op2); + + console.info("ServiceAbility serviceCenter sendRequest code = " + code); + + if (code == 2 || code == 4 ) { // 2为免安装 3为检查更新 4为安装 +// targetInfoCheck(transactId, op2) + } else if (code == 3) { +// serviceCheckUpdate(transactId, op2); + } +// else if (code == 4) { +// updateInfoCheck(transactId, op2); +// } + return true; + } +} + +async function targetInfoCheck(transactId: string, remoteObj: any) { + if (exterrcode != 0) { + console.info("ServiceAbility serviceCenter targetInfoCheck exterrcode = " + exterrcode); + let retcode = exterrcode; + console.info("ServiceAbility serviceCenter targetInfoCheck retcode = " + retcode); + sendCallBack(transactId, remoteObj, retcode); + } + else if ((targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication.ServiceAbility" && targetmoduleName === "myapplication" + ) || (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication6.ServiceAbility" && targetmoduleName === "myapplication6" + )) { + path = ["/data/storage/el2/base/haps/entry/files/myapp0.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication1.ServiceAbility_feature" && targetmoduleName === "myapplication1" + ) + || (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication1.MainAbility" && targetmoduleName === "myapplication1" + )) { + path = ["/data/storage/el2/base/haps/entry/files/myapp1.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication1.ServiceAbility_feature" && targetmoduleName === "myapplication3" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapp3.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication5.ServiceAbility5" && targetmoduleName === "myapplication5" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapp5.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication6.ServiceAbility6" && targetmoduleName === "myapplication6" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapp6.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication7.ServiceAbility" && targetmoduleName === "myapplication7" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapp7.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } else if ((targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication6.ServiceAbility6" && targetmoduleName === "myapplication8" + ) || (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication8.ServiceAbility" && targetmoduleName === "myapplication8" + )) { + path = ["/data/storage/el2/base/haps/entry/files/myapp8.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } else if (targetbundleName === "com.example.myapplication.hmservice" && + targetabilityName === "com.example.myapplication7.ServiceAbility" && targetmoduleName === "myapplication9" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapp9.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.ohos.atomic1.hmservice" && + targetabilityName === "MainAbility" + // && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/Atomic1_stage.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.ohos.atomic1.hmservice" && + targetabilityName === "com.ohos.atomic1.MainAbility" + // && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/Atomic1_FA.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.startAbilityForResult.hmservice" && + targetabilityName === "MainAbility1" && targetmoduleName === "myapplication1" + ) { + path = ["/data/storage/el2/base/haps/entry/files/yuanzihua-myapplication1.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.open.harmony.startAbilityForResult" && + targetabilityName === "com.example.myapplication1.MainAbility1" && targetmoduleName === "myapplication1" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapplication1-FA-2900.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } else if (targetbundleName === "com.open.harmony.startAbility" && + targetabilityName === "com.example.myapplication1.MainAbility1" && targetmoduleName === "myapplication1" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapplication1-FA-s2800.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.qianyiyingyong.MainAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.qianyiyingyong.ServiceAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.qianyiyingyong.MainAbility" && targetmoduleName === "hm1" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.hm3.MainAbility" && targetmoduleName === "hm3" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.hm2.MainAbility" && targetmoduleName === "hnm2" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "hm3MainAbility" && targetmoduleName === "hm3" + ) + || (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "hnm2MainAbility" && targetmoduleName === "hnm2" + ) + || (targetbundleName === "com.example.myapplication.hmservice0" && + targetabilityName === "com.example.myapplication.MainAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.example.myapplication.hmservice0" && + targetabilityName === "com.example.myapplication1.MainAbility" && targetmoduleName === "myapplication1" + ) + || (targetbundleName === "com.example.myapplication.hmservice0" && + targetabilityName === "com.example.myapplication2.MainAbility" && targetmoduleName === "myapplication2" + ) + || (targetbundleName === "com.open.harmony.myapplication0.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry" + ) + || (targetbundleName === "com.open.harmony.myapplication0.hmservice" && + targetabilityName === "MainAbility1" && targetmoduleName === "myapplication1" + ) + || (targetbundleName === "com.open.harmony.myapplication0.hmservice" && + targetabilityName === "MainAbility2" && targetmoduleName === "myapplication2" + ) + || (targetbundleName === "com.open.harmony.packagemag.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "myapplication1" + ) + ) { + path = ["/data/storage/el2/base/haps/entry/files"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.hm2.MainAbility" && targetmoduleName === "hm4" + ) { + path = ["/data/storage/el2/base/haps/entry/files/sign-core-hm4-all.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplicationA.hmserviceA" && + targetabilityName === "com.example.myapplicationA.MainAbility" && targetmoduleName === "entry" + ) || (targetbundleName === "com.open.harmony.myapplicationA.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry")) { + path = ["/data/storage/el2/base/haps/entry/files/A.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplicationB.hmserviceB" && + targetabilityName === "com.example.myapplicationB.MainAbility" && targetmoduleName === "entry" + ) || (targetbundleName === "com.open.harmony.myapplicationB.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry")) { + path = ["/data/storage/el2/base/haps/entry/files/B.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else if ((targetbundleName === "com.example.myapplicationC.hmserviceC" && + targetabilityName === "com.example.myapplicationC.MainAbility" && targetmoduleName === "entry" + ) || (targetbundleName === "com.open.harmony.myapplicationC.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "entry")) { + path = ["/data/storage/el2/base/haps/entry/files/C.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + else { + sendCallBack(transactId, remoteObj, -1); + } +} + +async function updateInfoCheck(transactId: string, remoteObj: any) { + //startAbility 高低版本 + if (targetbundleName === "com.example.qianyiyingyong.hmservice" && + targetabilityName === "com.example.qianyiyingyong.MainAbility" && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/sign-core-qianyi-allv2.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + //免安装更新 stage模型 + else if (targetbundleName === "com.ohos.atomic1.hmservice" && + targetabilityName === "MainAbility" + // && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/Atomic1_stage_V2.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + //免安装更新 FA模型 + else if (targetbundleName === "com.ohos.atomic1.hmservice" && + targetabilityName === "com.ohos.atomic1.MainAbility" + // && targetmoduleName === "entry" + ) { + path = ["/data/storage/el2/base/haps/entry/files/Atomic1_FA_V2.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + //免安装更新 同应用 Stage模型 + else if (targetbundleName === "com.ohos.myapplication.hmservice" && + targetabilityName === "MainAbility" && targetmoduleName === "myapplication" + ) { + path = ["/data/storage/el2/base/haps/entry/files/myapp_stage_V2.hap"]; + console.info("ServiceAbility serviceCenter targetInfoCheck path: " + JSON.stringify(path)); + serviceInstall(transactId, remoteObj); + } + + else { + sendCallBack(transactId, remoteObj, -1); + } +} + +async function serviceInstall(transactId: string, remoteObj: any) { + console.info('ServiceAbility serviceCenter install start'); + // let bundleFilePaths = ["/data/storage/el2/base/haps/entry/files/"]; + let bundleFilePaths = path; + let param = { + userId: 100, + installFlag: 16, + isKeepData: false + } + let installer = await bundle.getBundleInstaller(); + installer.install(bundleFilePaths, param, (err: any, data: any) => { + console.info('ServiceAbility serviceCenter install. Data status: ' + JSON.stringify(data.status)); + console.info('ServiceAbility serviceCenter install. Data statusMessage: ' + JSON.stringify(data.statusMessage)); + console.info('ServiceAbility serviceCenter install. bundleFilePaths:' + JSON.stringify(bundleFilePaths)); + console.info('ServiceAbility serviceCenter install. param:' + JSON.stringify(param)); + console.info('ServiceAbility serviceCenter install. Cause:' + JSON.stringify(err)); + sendcode = parseInt(err.code); + if (sendcode === -1) { + sendcode = -5; + } + console.info('ServiceAbility serviceCenter install. code:' + sendcode); + bundle.setModuleUpgradeFlag(targetbundleName, targetmoduleName, 0) + .then((data) => { + console.info('ServiceAbility serviceCenter install flag bundleName : ' + JSON.stringify(targetbundleName) + + ', moduleName : ' + JSON.stringify(targetmoduleName)); + console.info('ServiceAbility serviceCenter UpgradeFlag method, data: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('ServiceAbility serviceCenter install flag bundleName : ' + JSON.stringify(targetbundleName) + + ', moduleName : ' + JSON.stringify(targetmoduleName)); + console.error('ServiceAbility serviceCenter UpgradeFlag method, error: ' + JSON.stringify(error)); + }); + console.info("ServiceAbility serviceCenter serviceInstall callBack obj = " + remoteObj); + console.info("ServiceAbility serviceCenter serviceInstall code = " + sendcode); + sendCallBack(transactId, remoteObj, sendcode); + }); + +} + +async function serviceCheckUpdate(transactId: string, remoteObj: any) { + console.info('ServiceAbility serviceCenter serviceCheckUpdate start'); + bundle.setModuleUpgradeFlag(targetbundleName, targetmoduleName, 1) + .then((data) => { + console.info('ServiceAbility serviceCenter UpgradeFlag bundleName value: ' + JSON.stringify(targetbundleName)); + console.info('ServiceAbility serviceCenter UpgradeFlag moduleName value: ' + JSON.stringify(targetmoduleName)); + console.info('ServiceAbility serviceCenter UpgradeFlag method, data: ' + JSON.stringify(data)); + }).catch((error) => { + console.info('ServiceAbility serviceCenter UpgradeFlag bundleName value: ' + JSON.stringify(targetbundleName)); + console.info('ServiceAbility serviceCenter UpgradeFlag moduleName value: ' + JSON.stringify(targetmoduleName)); + console.error('ServiceAbility serviceCenter UpgradeFlag method, error: ' + JSON.stringify(error)); + }); + setTimeout(function () { + console.info("ServiceAbility serviceCenter serviceCheckUpdate sendCallBack sleep 35000 !!!") + sendCallBack(transactId, remoteObj, 0); + },35000) +} + +function sendCallBack(transactId: string, remoteObj: any, code: number) { + console.info("ServiceAbility serviceCenter sendCallBack remoteObj = " + remoteObj); + let option1 = new rpc.MessageOption(); + let data1 = rpc.MessageParcel.create(); + let reply1 = rpc.MessageParcel.create(); + // 写入token + // data1.writeInterfaceToken("ohos.aafwk.IAtomicServiceStatusCallback"); + data1.writeInterfaceToken("abilitydispatcherhm.openapi.hapinstall.IHapInstallCallback"); + // 将BMS传递的transactId返回给BMS + installResult.result.transactId = transactId; + installResult.result.retCode = code; + console.info('ServiceAbility serviceCenter code:' + code); + let returnString = JSON.stringify(installResult); + console.info("ServiceAbility serviceCenter sendRequest returnString = " + returnString); + // 返回给BMS的参数 -- json字符串 + data1.writeString(returnString); + remoteObj.sendRequest(1, data1, reply1, option1, (err, result) => { + console.info("ServiceAbility serviceCenter sendRequest result:" + result + ",err:" + err); + if (err === 0) { + console.info("ServiceAbility serviceCenter sendRequest got result"); + } + }); +} + + + +export default class ServiceExtAbility extends ServiceExtensionAbility { + onCreate(want) { + console.info('onCreate, want:' + want.abilityName); + console.info('ServiceAbility serviceCenter onCreate'); + } + + onRequest(want, startId) { + console.info('onRequest, want: ' + want.abilityName); + console.info('onRequest, startId: ' + startId); + console.info('ServiceAbility serviceCenter onRequest'); + } + + onConnect(want) { + // console.info('onConnect, want:' + want.abilityName); + console.info('ServiceAbility serviceCenter onConnect'); + return new StubTest("test"); + } + + onDisconnect(want) { + console.info('onDisconnect, want:' + want.abilityName); + console.info('ServiceAbility serviceCenter onDisconnect'); + } + + onReconnect(want) { + console.info('onReconnect, want:' + want.abilityName); + console.info('ServiceAbility serviceCenter onReconnect'); + } + + onDestroy() { + console.info('ServiceAbility serviceCenter onDestroy'); + } +} diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..101a1580a2a7c95f0200a1d3a7dd4df6cd538402 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 serviceCenter' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..a004f10a8b3aca76970352096e3bb3f8f2323bdf --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/module.json @@ -0,0 +1,48 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "requestPermissions": [ {"name": "ohos.permission.INSTALL_BUNDLE"}], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "HapInstallServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service", + "visible": true, + "icon": "$media:icon" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..c3d85e5418e6e92ed6134d6690b5cbec5cf80256 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "Mockservice" + }, + { + "name": "form_ServiceAbility_desc", + "value": "service" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/mockservicetimeout/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/mockservicetimeout/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/mockservicetimeout/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/mockservicetimeout/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8d76e942f904a658a9f274791419e3ebeb72e59c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationFaEntry") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":atomizationfaentry_ets_assets", + ":atomizationfaentry_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "AtomizationFaEntry" +} +ohos_js_assets("atomizationfaentry_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("atomizationfaentry_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/Test.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..5f34d6beac8cc14c6252a9727f1e6ebd5268069b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/config.json @@ -0,0 +1,96 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.qianyiyingyong", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": true + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "visible": true, + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability", + "type": "service" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second", + "pages/third" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO", + "reason": "need use ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e4a01f780ed405b1dd2ee75672d998ac3e18501 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import featureAbility from '@ohos.ability.featureAbility'; +export default { + onCreate() { + console.info('Application onCreate') + setTimeout(function () { + featureAbility.terminateSelf() + .then((data) => { + console.info('entry terminateself succeeded: ' + data); + }).catch((error) => { + console.error('entry terminateself failed. Cause: ' + error); + }) + }, 1000); + }, + onDestroy() { + console.info('Application onDestroy') + }, + onStartContinuation() { + console.info('onStartContinuation'); + return true; + }, + onRestoreData(data) { + console.info('onRestoreData' + data); + return true; + }, + onSaveData(data) { + console.info('onSaveData'); + return true; + }, + onCompleteContinuation(result) { + console.info('onCompleteContinuation:' + result); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/model/getRemoteDeviceModel.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/model/getRemoteDeviceModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..1588ea0a222e06acd3076fc00e0dc3fb864ed0f3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/model/getRemoteDeviceModel.ets @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2022 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 deviceManager from '@ohos.distributedHardware.deviceManager'; + +var SUBSCRIBE_ID = 100; + +export default class RemoteDeviceModel { + deviceList = []; + deviceManager; + + constructor() { + } + + registerDeviceListCallback() { + if (typeof (this.deviceManager) === 'undefined') { + console.log('[dmsDemo] deviceManager.createDeviceManager begin'); + let self = this; + deviceManager.createDeviceManager('com.ohos.distributedmusicplayer', (error, value) => { + if (error) { + console.error('createDeviceManager failed.'); + return; + } + self.deviceManager = value; + self.registerDeviceListCallback_(); + console.log('[dmsDemo] createDeviceManager callback returned, error=' + error + ' value=' + JSON.stringify(value)); + }); + console.log('[dmsDemo] deviceManager.createDeviceManager end'); + } else { + this.registerDeviceListCallback_(); + } + } + + registerDeviceListCallback_(){ + console.info('[dmsDemo] registerDeviceListCallback'); + if (this.deviceManager == undefined) { + console.error('[dmsDemo] deviceManager has not initialized'); + return; + } + + console.info('[dmsDemo] getTrustedDeviceListSync begin'); + var list = this.deviceManager.getTrustedDeviceListSync(); + console.info('[dmsDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); + if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') { + this.deviceList = list; + } + console.info('[dmsDemo] callback finished'); + } + + unregisterDeviceListCallback() { + console.info('[dmsDemo] stopDeviceDiscovery ' + SUBSCRIBE_ID); + this.deviceManager.stopDeviceDiscovery(SUBSCRIBE_ID); + this.deviceList = []; + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..b3d41d3f33250d0646cfda1552440378ba5e803b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; +import featureAbility from '@ohos.ability.featureAbility' + +async function routePage(uri) { + let options = { + uri: uri + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('QianYi Entry MainAbility V1') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage('pages/second') + }) + + Button() { + Text('同应用不需要检查targetbundlelist名单') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage('pages/third') + }) + + Button() { + Text('StartAbilityForResult') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + this.terminateSelfWithResult(); + }) + } + .width('100%') + .height('100%') + } + + async terminateSelfWithResult() { + console.info('startAbilityForResultPromise terminateSelfWithResult START'); + await featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "com.example.qianyiyingyong.MainAbility", + }, + } + ); + await featureAbility.terminateSelf(); + console.info('startAbilityForResultPromise terminateSelfWithResult END'); + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..9dcd951896be78626c21d48cf64296d4194f8a81 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/third.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/third.ets new file mode 100644 index 0000000000000000000000000000000000000000..23790bb70f82ad346ccbe87078e6f27614b232ae --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/MainAbility/pages/third.ets @@ -0,0 +1,386 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; +import featureAbility from '@ohos.ability.featureAbility'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; +import RemoteDeviceModel from '../model/getRemoteDeviceModel.ets'; +import bundleManager from '@ohos.bundle'; + +const BUNDLE_NAME = 'com.example.qianyiyingyong.hmservice'; +const ABILITY_NAME = 'com.example.qianyiyingyong.MainAbility'; +const ABILITY_NAME1 = 'com.example.hm2.MainAbility'; +const ABILITY_NAME2 = 'com.example.hm3.MainAbility'; +const MODULE_NAME_ENTRY = 'entry'; +const MODULE_NAME_HNM2 = 'hnm2'; +const MODULE_NAME_HNM3 = 'hm3'; + +let remoteDeviceId = ''; +let remoteDeviceModel = null; + +@Entry +@Component +struct Third { + private content: string = "Third Page" + private contextText: string= ''; + private localDeviceId: string= ''; + private backgroundColor = Color.Grey; + private tipsMsg = '请输入对端的deviceId'; + private isOn = false; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold); + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold); + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back(); + }); + Row() { + Text('关闭是startAbility,打开是startAbilityForResult:') + .fontSize(20) + .fontWeight(FontWeight.Bold); + + Toggle({ type: ToggleType.Switch, isOn: this.isOn }) + .width($r('app.float.wh_value_50')) + .height($r('app.float.wh_value_40')) + .onChange((isOn) => { + console.info('startAbility startAbilityPromise isOn:' + isOn); + this.isOn = isOn; + console.info('startAbility startAbilityPromise this.isOn:' + this.isOn); + }); + } + .margin({ right: $r('app.float.wh_value_15') }) + .align(Alignment.End); + TextInput({ placeholder: '请输入deviceId', text: this.contextText }) + .placeholderColor(Color.Blue) + .placeholderFont({ + size: $r('app.float.wh_value_20'), + weight: 2, + family: "sans-serif", + style: FontStyle.Normal + }) + .caretColor(Color.Blue) + .height($r('app.float.wh_value_70')) + .backgroundColor(Color.White) + .type(InputType.Normal) + .width('100%') + .fontStyle(FontStyle.Italic) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) + .onChange((value: string) => { + this.contextText = value; + }); + + Text('StartAbilityPromise006,在免安装更新的时候需先设置updateModuleUpgradeFlag') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + this.updateModuleUpgradeFlag('StartAbilityPromise006','entry'); + }); + + Text('StartAbilityPromise017,本应用不同AbilityName') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'moduleName': MODULE_NAME_HNM2, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + if (this.isOn) { + this.startAbilityForResultPromise('StartAbilityPromise017', str); + } else { + this.startAbilityPromise('StartAbilityPromise017', str); + } + }); + + Text('StartAbilityPromise018,高低版本entry覆盖安装') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME, + 'moduleName': MODULE_NAME_ENTRY, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + this.startAbilityPromise('StartAbilityPromise018', str); + }); + + Text('StartAbilityPromiseKSB013,原子化服务未添加到targetBundleList里,同应用不同AbilityName') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + if ('' === remoteDeviceId && '' === this.contextText) { + this.tips(this.tipsMsg); + return; + } + var str = { + 'want': { + 'deviceId': '' === this.contextText ? remoteDeviceId : this.contextText, + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'moduleName': MODULE_NAME_HNM2, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + if (this.isOn) { + this.startAbilityForResultPromise('StartAbilityPromiseKSB013', str); + } else { + this.startAbilityPromise('StartAbilityPromiseKSB013', str); + } + }); + + Text('StartAbilityPromiseKSB006,在免安装更新的时候需先设置updateModuleUpgradeFlag') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + this.updateModuleUpgradeFlag('StartAbilityPromiseKSB006','entry'); + }); + + Text('StartAbilityPromiseKSB015 跨设备 entry覆盖安装') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'deviceId': '' === this.contextText ? remoteDeviceId : this.contextText, + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME, + 'moduleName': MODULE_NAME_ENTRY, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + this.startAbilityPromise('StartAbilityPromiseKSB015', str); + }); + + Text('StartAbilityPromiseKSB016,原子化服务未添加到targetBundleList里,跨设备,同应用,对端FA的visable为false无法拉起') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + if ('' === remoteDeviceId && '' === this.contextText) { + this.tips(this.tipsMsg); + return; + } + var str = { + 'want': { + 'deviceId': '' === this.contextText ? remoteDeviceId : this.contextText, + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME2, + 'moduleName': MODULE_NAME_HNM3, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + if (this.isOn) { + this.startAbilityForResultPromise('StartAbilityPromiseKSB016', str); + } else { + this.startAbilityPromise('StartAbilityPromiseKSB016', str); + } + }); + + Text('StartAbilityPromiseKSB014,原子化服务未添加到targetBundleList里,' + + '同应用不同AbilityName,无跨设备权限(拉起应用或被拉起应用)') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'deviceId': '' === this.contextText ? remoteDeviceId : this.contextText, + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'moduleName': MODULE_NAME_HNM2, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + if (this.isOn) { + this.startAbilityForResultPromise('StartAbilityPromiseKSB014', str); + } else { + this.startAbilityPromise('StartAbilityPromiseKSB014', str); + } + }); + } + .width('100%') + .height('100%') + } + + async updateModuleUpgradeFlag(tag, type1) { + console.info(tag + ' startAbility startAbilityPromise START' + JSON.stringify(type1)); + await bundleManager.setModuleUpgradeFlag("com.example.qianyiyingyong.hmservice",type1,1); + console.info(tag + ' startAbility startAbilityPromise END'); + } + + async startAbilityPromise(tag, str) { + console.info(tag + ' startAbility startAbilityPromise START' + JSON.stringify(str)); + let code; + await featureAbility.startAbility(str) + .then((data) => { + console.info(tag + ' startAbility Operation successful. Promise Data: ' + JSON.stringify(data)) + code = data; + }).catch((error) => { + console.info(tag + ' startAbility Operation failed. Promise Cause: ' + JSON.stringify(error)); + code = error; + }) + console.info(tag + ' startAbility Operation code Promise: ' + JSON.stringify(code)); + if (code === 0) { + this.tips('成功'); + } else { + this.tips('错误码:' + code.code); + } + console.info(tag + ' startAbility startAbilityPromise END'); + } + + async startAbilityCallBack(tag, str) { + let code; + console.info(tag + 'startAbility startAbilityCallBack START' + JSON.stringify(str)); + featureAbility.startAbility(str, (err, data) => { + code = data; + if (err) { + console.error(tag + ' Operation failed. CallBack Cause:' + JSON.stringify(err)); + code = err; + } + if (code === 0) { + this.tips('成功'); + } else { + this.tips('错误码:' + code.code); + } + console.info('Operation successful. CallBack Data: ' + JSON.stringify(data)) + }); + console.info(tag + 'startAbility startAbilityCallBack END'); + } + + async startAbilityForResultPromise(tag, str) { + console.info(tag + ' startAbilityForResultPromise START' + JSON.stringify(str)); + let newData; + await featureAbility.startAbilityForResult(str) + .then((data) => { + this.tips('成功'); + newData = data; + console.info(tag + ' startAbilityForResultPromise Operation successful. Promise Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(tag + ' startAbilityForResultPromise Operation failed. Promise Cause: ' + JSON.stringify(error)); + newData = error; + this.tips('失败'); + }) + console.info(tag + ' startAbilityForResultPromise Operation newData Promise: ' + JSON.stringify(newData)); + console.info(tag + ' startAbilityForResultPromise startAbilityPromise END'); + } + + async startAbilityForResultCallBack(tag, str) { + console.info(tag + 'startAbilityForResultCallBack START' + JSON.stringify(str)); + featureAbility.startAbilityForResult(str, (err, data) => { + console.info(tag + 'startAbilityForResultCallBack Operation CallBack Data: ' + JSON.stringify(data)) + if (err) { + this.tips('失败'); + console.info(tag + 'startAbilityForResultCallBack Operation CallBack err:' + JSON.stringify(err)); + return; + } + this.tips('成功'); + }); + console.info(tag + 'startAbilityForResultCallBack END'); + } + + tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } + + onBackPress() { + console.log('[startAbility] get device onBackPress in'); + this.contextText = ''; + console.log('[startAbility] get device onBackPress out'); + } + + private aboutToAppear(): void { + console.info('[startAbility] aboutToAppear in'); + remoteDeviceModel = new RemoteDeviceModel; + remoteDeviceModel.registerDeviceListCallback(); + console.info('[startAbility] aboutToAppear end'); + } + + onPageShow(): void{ + console.info('[startAbility] onPageShow in'); + let numDevices = remoteDeviceModel.deviceList.length; + if (numDevices === 0) { + this.tips('onStartRemoteAbility no device found') + return; + } + remoteDeviceId = remoteDeviceModel.deviceList[0].deviceId; + console.info('[startAbility] onPageShow deviceId is ' + remoteDeviceId); + } + + private aboutToDisappear() { + console.info('[startAbility] aboutToDisappear in'); + remoteDeviceModel.unregisterDeviceListCallback(); + console.info('[startAbility] aboutToDisappear out'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..20fa2029c83293f10296392723d99694245ae720 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,26 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onStart() { + console.info('qianyiyingyong ServiceAbility onStart'); + }, + onStop() { + console.info('qianyiyingyong ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('qianyiyingyong ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/element/float.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..6f8d0c2063b868636f443046d8d777b0c4e3ab3f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/element/float.json @@ -0,0 +1,124 @@ +{ + "float": [ + { + "name": "wh_value_1", + "value": "1" + }, + { + "name": "wh_value_5", + "value": "5" + }, + { + "name": "wh_value_10", + "value": "10" + }, + { + "name": "wh_value_15", + "value": "15" + }, + { + "name": "wh_value_20", + "value": "20" + }, + { + "name": "wh_value_30", + "value": "30" + }, + { + "name": "wh_value_40", + "value": "40" + }, + { + "name": "wh_value_50", + "value": "50" + }, + { + "name": "wh_value_60", + "value": "60" + }, + { + "name": "wh_value_65", + "value": "65" + }, + { + "name": "wh_value_70", + "value": "70" + }, + { + "name": "wh_value_80", + "value": "80" + }, + { + "name": "wh_value_100", + "value": "100" + }, + { + "name": "wh_value_130", + "value": "1300" + }, + { + "name": "wh_value_160", + "value": "160" + }, + { + "name": "wh_value_230", + "value": "230" + }, + { + "name": "wh_value_280", + "value": "280" + }, + { + "name": "wh_value_390", + "value": "390" + }, + { + "name": "wh_value_400", + "value": "400" + }, + { + "name": "font_35", + "value": "35" + }, + { + "name": "font_18", + "value": "18" + }, + { + "name": "font_20", + "value": "20" + }, + { + "name": "font_21", + "value": "21" + }, + { + "name": "font_22", + "value": "22" + }, + { + "name": "font_24", + "value": "24" + }, + { + "name": "font_28", + "value": "28" + }, + { + "name": "font_50", + "value": "50" + }, + { + "name": "control_common_font_size", + "value": "20" + }, + { + "name": "slider_text_padding_left", + "value": "5" + }, + { + "name": "volume_border_radius", + "value": "15" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0532654394e0ffa53b6d6ea673a420da69d921e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "迁移111" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfaentry/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..05022a1a7f1fabdc0db577c4e9003d23d708853f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationFaHm2") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":atomizationfahm2_ets_assets", + ":atomizationfahm2_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "AtomizationFaHm2" +} +ohos_js_assets("atomizationfahm2_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("atomizationfahm2_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/Test.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..955bdfd3893ca836c467e7197348a0d757360d28 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/config.json @@ -0,0 +1,63 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.hm2", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "hnm2", + "moduleType": "feature", + "installationFree": true + }, + "abilities": [ + { + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:hnm2_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..5737bf718ac51c5af914d415099513cd0eba292e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import featureAbility from '@ohos.ability.featureAbility'; +export default { + onCreate() { + console.info('Application onCreate') + setTimeout(function () { + featureAbility.terminateSelf() + .then((data) => { + console.info('hm2 terminateself succeeded: ' + data); + }).catch((error) => { + console.error('hm2 terminateself failed. Cause: ' + error); + }) + }, 1000); + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..855b203accb89d6ec76ab95d647bc012b7820139 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; +import featureAbility from '@ohos.ability.featureAbility' +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; + +const BUNDLE_NAME = 'com.example.qianyiyingyong.hmservice'; +const ABILITY_NAME1 = 'com.example.hm2.MainAbility'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + + private backgroundColor = Color.Grey; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('hm2') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('HNM2 next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + + Text('startAbilityPromiseSameBundleName1 本设备,feature覆盖安装') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + this.startAbilityPromise('startAbilityPromiseSameBundleName1', str); + + }); + + Button() { + Text('StartAbilityForResult') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + this.terminateSelfWithResult(); + }) + } + .width('100%') + .height('100%') + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } + + async terminateSelfWithResult() { + console.info('startAbilityForResultPromise terminateSelfWithResult START'); + await featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "com.example.hm2.MainAbility", + }, + } + ); + await featureAbility.terminateSelf(); + console.info('startAbilityForResultPromise terminateSelfWithResult END'); + } + + async startAbilityPromise(tag, str) { + console.info(tag + ' startAbility startAbilityPromise START' + JSON.stringify(str)); + let code; + await featureAbility.startAbility(str) + .then((data) => { + console.info(tag + ' startAbility Operation successful. Promise Data: ' + JSON.stringify(data)) + code = data; + }).catch((error) => { + console.info(tag + ' startAbility Operation failed. Promise Cause: ' + JSON.stringify(error)); + code = error; + }) + console.info(tag + ' startAbility Operation code Promise: ' + JSON.stringify(code)); + if (code === 0) { + this.tips('成功'); + } else { + this.tips('错误码:' + code.code); + } + console.info(tag + ' startAbility startAbilityPromise END'); + } + + tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e0296ed6e5ec446039002974e449266f2ed14f4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "HNM2 Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8380229de102511d01d094185835cbe3c975d9d8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "hnm2_MainAbility", + "value": "相同BN不同AN" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..194d8992bf10df9b4855d56e59e1e2979f28352e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationFaHm4") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":atomizationfahm4_ets_assets", + ":atomizationfahm4_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "AtomizationFaHm4" +} +ohos_js_assets("atomizationfahm4_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("atomizationfahm4_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/Test.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..196f92b9e193372f7559658e8c75810258051cc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/config.json @@ -0,0 +1,63 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "ohos", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.hm2", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "hm4", + "moduleType": "feature", + "installationFree": true + }, + "abilities": [ + { + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:hm4_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..08ec6e2afac1d90aa81fa72b1c3684ead0a65540 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import featureAbility from '@ohos.ability.featureAbility'; +export default { + onCreate() { + console.info('Application onCreate') + setTimeout(function () { + featureAbility.terminateSelf() + .then((data) => { + console.info('hm4 terminateself succeeded: ' + data); + }).catch((error) => { + console.error('hm4 terminateself failed. Cause: ' + error); + }) + }, 1000); + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..019e8a3953de22c6b4ac10dbe1b7cdc4ed5cae1e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('hm4') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..e728121a18c43f9e395cec7813124a4a3b128874 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f7546310bc8388ebedbdde9478cc2c49131196f5 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "hm4_MainAbility", + "value": "hm4_MainAbility" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/atomizationfahm4/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..8d7e2116799cbf2c26ec45b6777b56d636e16a8c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FaMyApplication1") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":famyapplication1_ets_assets", + ":famyapplication1_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FaMyApplication1" +} +ohos_js_assets("famyapplication1_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("famyapplication1_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/Test.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..55e61015dc7ce7a49ebf939e46b0f2b1091d3839 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/config.json @@ -0,0 +1,72 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.open.harmony.startAbility", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility1", + "deviceType": [ + "phone" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility1", + "name": ".MainAbility1", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility1_desc", + "formsEnabled": false, + "label": "$string:MainAbility1_label", + "type": "page", + "launchType": "standard" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication1" + }, + "package": "com.example.myapplication1", + "srcPath": "", + "name": ".myapplication1", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility1", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..c5303cfeff9a657c16179526c8dba8816853d3b6 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + console.info('Application onCreate') + setTimeout(function () { + featureAbility.terminateSelf() + .then((data) => { + console.info('MainAbility1 terminateself succeeded: ' + data); + }).catch((error) => { + console.error('MainAbility1 terminateself failed. Cause: ' + error); + }) + }, 1000); + }, + + onActive(){ + console.info('onActive'); + }, + + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb5ac58410e01463816bf3127d933e4ebef5376c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 = 'Same app - not need to check targetbundlelist' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0ab9f9b1dcb2df0331476e1ae3619426cf2b3b47 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "myapplication1_desc", + "value": "description" + }, + { + "name": "MainAbility1_desc", + "value": "description" + }, + { + "name": "MainAbility1_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/famyapplication1/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..f220be14067f7265ae3974515b2bee0dc2d09890 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/BUILD.gn @@ -0,0 +1,34 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FreeInstallStartAbilityFaTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":freeinstallstartabilityfatest_ets_assets", + ":freeinstallstartabilityfatest_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FreeInstallStartAbilityFaTest" +} +ohos_js_assets("freeinstallstartabilityfatest_ets_assets") { + source_dir = "./entry/src/main/ets" + hap_profile = "entry/src/main/config.json" + ets2abc = true +} +ohos_resources("freeinstallstartabilityfatest_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/Test.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..49286efd7644c24254bf06aca3ab24cd33ca4e6c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/Test.json @@ -0,0 +1,36 @@ +{ + "description": "Configuration for freeinstallstartabilityfatest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.open.harmony.startAbility", + "package-name": "com.open.harmony.startAbility", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "FreeInstallStartAbilityFaTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "AtomizationFaEntry.hap -> /data/test/AtomizationFaEntry.hap", + "AtomizationFaHm2.hap -> /data/test/AtomizationFaHm2.hap", + "AtomizationFaHm4.hap -> /data/test/AtomizationFaHm4.hap", + "MockService.hap -> /data/test/MockService.hap", + "MockServiceTimeout.hap -> /data/test/MockServiceTimeout.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..97395cdbcdb1ab33a3816a1f542469fc0397a015 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/config.json @@ -0,0 +1,139 @@ +{ + "app": { + "targetBundleList": [ + "com.example.qianyiyingyong.hmservice" + ], + "vendor": "example", + "bundleName": "com.open.harmony.startAbility", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "srcPath": "PageAbility", + "name": ".PageAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:PageAbility_desc", + "formsEnabled": false, + "label": "$string:PageAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": "com.open.harmony.startAbility.ServiceAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:ServiceAbility_desc", + "type": "service" + } + ], + "distro": { + "moduleType": "entry", + "installationFree": false, + "deliveryWithInstall": true, + "moduleName": "entry" + }, + "package": "com.open.harmony.startAbility", + "srcPath": "", + "name": ".entry", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".PageAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "reason": "need use ohos.permission.INSTALL_BUNDLE", + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.MANAGE_MISSIONS" + }, + { + "reason": "need use ohos.permission.INSTALL_BUNDLE", + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "reason": "need use ohos.permission.REMOVE_CACHE_FILES", + "name": "ohos.permission.REMOVE_CACHE_FILES" + }, + { + "reason": "need use ohos.permission.LISTEN_BUNDLE_CHANGE", + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8800e52414c0cd250b0db931fba3d789f8bd9db3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,85 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 router from '@system.router'; +import file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend,expect} from "deccjsunit/index"; +import testsuite from "../test/List.test"; +import featureAbility from "@ohos.ability.featureAbility"; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + Want.parameters.timeout = 50000; + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text(' FA- StartAbility TEST ') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..91ea52129f9332d91f4b842b31abcb2685ad620e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 startAbilityTest from "./StartAbility.test"; +import startAbilityTest2 from "./StartAbility.test2"; + +export default function testsuite() { + startAbilityTest(); + startAbilityTest2(); + +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/StartAbility.test.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/StartAbility.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d38e9f56d791fc4c98cfc938c4c723f89f8d8397 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/StartAbility.test.ets @@ -0,0 +1,1126 @@ + +/** + * Copyright (c) 2022 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 "deccjsunit/index"; +import featureAbility from "@ohos.ability.featureAbility"; +import wantConstant from '@ohos.ability.wantConstant'; +import abilityManager from '@ohos.application.abilityManager'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import commonEvent from '@ohos.commonEvent'; + +export default function startAbilityTest() { + + describe('startAbilityTest', function () { + + console.info("-------------FA model--> startAbilityXTS Test start----------------") + + var TAG = ""; + + var delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + var subscriber; + var result; + var subscribeInfo = { + events: ["service_event"] + }; + + function SubscribeCallBack(err, data) { + if (err.code) { + console.error("Testevent subscribe failed " + JSON.stringify(err)); + } else { + console.info("Testevent subscribe " + JSON.stringify(data)); + for (var key1 in data.parameters) { + console.info("Testevent data.parameters[key] is :" + data.parameters[key1]) + if (data.parameters[key1] === "onSuccess") { + result = "onSuccess" + } + } + } + } + + function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("Testevent createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("Testevent createSubscriber"); + subscriber = commonEventSubscriber; + commonEvent.subscribe(subscriber, SubscribeCallBack); + } + } + + beforeAll(async function (done) { + console.info("StartAbilityForResult before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityTest after each called"); + if ("FreeInstall_FA_Local_StartAbility_0200" === TAG || + "FreeInstall_FA_Local_StartAbility_0500" === TAG || + "FreeInstall_FA_Local_StartAbility_0700" === TAG || + "FreeInstall_FA_Local_StartAbility_0800" === TAG || + "FreeInstall_FA_Local_StartAbility_1000" === TAG || + "FreeInstall_FA_Local_StartAbility_1200" === TAG || + "FreeInstall_FA_Local_StartAbility_1400" === TAG || + "FreeInstall_FA_Local_StartAbility_1600" === TAG || + "FreeInstall_FA_Local_StartAbility_1800" === TAG || + "FreeInstall_FA_Local_StartAbility_2200" === TAG || + "FreeInstall_FA_Local_StartAbility_3000" === TAG || + "FreeInstall_FA_Local_StartAbility_3400" === TAG || + "FreeInstall_FA_Local_StartAbility_3600" === TAG || + "FreeInstall_FA_Local_StartAbility_3700" === TAG || + "FreeInstall_FA_Local_StartAbility_3800" === TAG) { + var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + } + + if ("FreeInstall_FA_Local_StartAbility_3800" === TAG) { + var cmd5 = "bm uninstall -n com.ohos.hag.famanager"; + delegator.executeShellCommand(cmd5, (err: any, d: any) => { + console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await sleep(500); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0100 + * @tc.name The deviceid passed in is null, so the installation free process is implemented + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0100", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0100-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_0100"; + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_0100-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0200 + * @tc.name The passed in deviceid is empty, and the installed apps are automatically pulled up + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0200", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0200-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_0200"; + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_0200-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0300 + * @tc.name The deviceid passed in is empty. There is no need to install or installed HAP package + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0300", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0300-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0300"; + var cmd300 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd300, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let wrong; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(1000); + expect(wrong.code).assertEqual(4); + console.info("------------end FreeInstall_FA_Local_StartAbility_0300-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0400 + * @tc.name Do not transfer deviceid to realize installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0400", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0400-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_0400"; + var cmd400 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd400, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_0400-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0500 + * @tc.name The installed application will be automatically pulled up without transmitting the deviceid + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0500", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0500-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_0500"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_0500-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0600 + * @tc.name Manually obtain and pass in the deviceid of the device to realize the installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0600", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0600-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_0600"; + var deviceId = ""; + await abilityManager.getTopAbility((err, data) => { + console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err)); + console.log(TAG + 'getTopAbility result deviceId:' + JSON.stringify(data.ability.deviceId)); + deviceId = data.ability.deviceId; + }) + await sleep(1000); + let details; + var str = { + 'want': { + "deviceId": deviceId, + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_0600-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0700 + * @tc.name Manually obtain and pass in the deviceid of the device, + and the installed application will be automatically pulled up + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0700", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0700-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_0700"; + var deviceId = ""; + await abilityManager.getTopAbility((err, data) => { + console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err)); + console.log(TAG + 'getTopAbility result deviceId:' + JSON.stringify(data.ability.deviceId)); + deviceId = data.ability.deviceId; + }) + await sleep(1000); + let details; + var str = { + 'want': { + "deviceId": deviceId, + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_0700-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0800 + * @tc.name Without passing deviceid, pull up the HAP with the same bundlename and different + abilityname as the entry to realize the installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0800", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0800-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_0800"; + var cmd800 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd800, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd801 = "cp data/test/AtomizationFaHm2.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd801, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hnm2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_0800-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_0900 + * @tc.name Do not transfer deviceid, use callback to realize installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_0900", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_0900-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_0900"; + var cmd900 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaHm2.hap"; + delegator.executeShellCommand(cmd900, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd901 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd901, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str, (error, data) => { + console.log(TAG + ": startAbility err: " + JSON.stringify(error) + ",data: " + JSON.stringify(data)); + details = data; + }) + setTimeout(function () { + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_0900-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1000 + * @tc.name Do not transmit deviceid, and use callback to automatically pull up installed applications + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1000", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1000-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1000"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str, (error, data) => { + console.log(TAG + ": startAbility err: " + JSON.stringify(error) + ",data: " + JSON.stringify(data)); + details = data; + }) + setTimeout(function () { + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_1000-------------"); + done(); + }, 4000); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1100 + * @tc.name Flags=1717 of the incoming error. There is a hap package that needs to + be installed free under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1100", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1100-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1100"; + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": 1717, + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(1); + console.info("------------end FreeInstall_FA_Local_StartAbility_1100-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1200 + * @tc.name Bad flags=1717 passed in, atomized HAP package installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1200", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1200-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1200"; + var cmd1200 = "bm install -p data/test/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd1200, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": 1717, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_1200-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1300 + * @tc.name Flags= '94.31' of the incoming error. There is a hap package that + needs to be installed free under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1300", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1300-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1300"; + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": '94.31' + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(1); + console.info("------------end FreeInstall_FA_Local_StartAbility_1300-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1400 + * @tc.name Flags= '94.31' of incoming error, atomized HAP package installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1400", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1400-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1400"; + var cmd1400 = "bm install -p data/test/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd1400, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": '94.31' + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_1400-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1500 + * @tc.name Flags= '' of the incoming error. There is a hap package that needs to be + installed under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1500", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1500-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1500"; + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": '' + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(1); + console.info("------------end FreeInstall_FA_Local_StartAbility_1500-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1600 + * @tc.name Bad flags= ', atomized HAP package installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1600", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1600-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1600"; + var cmd1600 = "bm install -p data/test/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd1600, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": '' + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_1600-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1700 + * @tc.name No flag is transmitted, and there are HAP packages that need to be installed under + the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1700", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1700-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1700" + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry" + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(1); + console.info("------------end FreeInstall_FA_Local_StartAbility_1700-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1800 + * @tc.name No flag is transmitted, and the atomized HAP package is installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1800", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1800-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1800"; + var cmd1800 = "bm install -p data/test/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd1800, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_1800-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_2100 + * @tc.name The parameters field is passed in the want to realize the installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_2100", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_2100-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_2100"; + let details; + var str = { + 'want': { + 'bundleName': "com.example.qianyiyingyong.hmservice", + 'abilityName': "com.example.qianyiyingyong.MainAbility", + 'moduleName': "entry", + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + 'parameters': { + "name": "1111", + "Ext2": "ExtValue2", + "site": "很开心看到你!" + } + } + }; + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + details = data; + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_2100-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_2200 + * @tc.name The parameters field is passed in the want, and the installed applications + are automatically pulled up + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_2200", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_2200-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_2200"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + "parameters": { + "name": "1111", + "Ext2": "ExtValue2", + "site": "很开心看到你!" + } + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_2200-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3000 + * @tc.name There are hapa and hapb with the same bundlename and abilityname and different modulenames. + Under the specified path, there are hapa with correct input parameters that need not be installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3000", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3000-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3000"; + var cmd3000 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd3000, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3001 = "cp data/test/AtomizationFaHm4.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd3001, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hm4", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_3000-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3100 + * @tc.name There are hapa and hapb with the same bundlename and abilityname and different modulenames. + Hapb with input parameter error exists in the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3100", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3100-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3100"; + var cmd3100 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaHm4.hap"; + delegator.executeShellCommand(cmd3100, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3101 = "cp data/test/AtomizationFaHm2.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd3101, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hm4", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(4); + console.info("------------end FreeInstall_FA_Local_StartAbility_3100-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3200 + * @tc.name Transfer wrong moduleName + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3200", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3200-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3200"; + var cmd3200 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaHm2.hap"; + delegator.executeShellCommand(cmd3200, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3201 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd3201, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "hnm", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(1); + console.info("------------end FreeInstall_FA_Local_StartAbility_3200-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3300 + * @tc.name Do not transfer moduleName. There are HAP packages that need not be + installed under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3300", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3300-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3300"; + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(1); + console.info("------------end FreeInstall_FA_Local_StartAbility_3300-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3400 + * @tc.name Do not transfer moduleName. Atomized HAP package is installed. Start hap successfully. + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3400", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3400-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3400"; + var cmd3400 = "bm install -p data/test/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd3400, (err: any, d: any) => { + console.info("executeShellCommand3400 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_3400-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3500 + * @tc.name Transfer abilityStartSetting, so the installation free process is implemented + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3500", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3500-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3500"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_3500-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3600 + * @tc.name Transfer abilityStartSetting, so the installation free process is implemented + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3600", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3600-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3600"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_3600-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3700 + * @tc.name Service to pull up the service of the atomized service to realize the installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3700", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3700-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3700"; + commonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); + var str = { + 'want': { + "bundleName": "com.open.harmony.startAbility", + "abilityName": "com.open.harmony.startAbility.ServiceAbility", + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(result).assertEqual("onSuccess"); + console.info("------------end FreeInstall_FA_Local_StartAbility_3700-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_3800 + * @tc.name Add BACKGROUND flags, free install successfully. + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_3800", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_3800-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_3800"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE|wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(details).assertEqual(0); + console.info("------------end FreeInstall_FA_Local_StartAbility_3800-------------"); + done(); + }); + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/StartAbility.test2.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/StartAbility.test2.ets new file mode 100644 index 0000000000000000000000000000000000000000..eedbb2ed68075a2777e75c60072a1eb7999d2c86 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/StartAbility.test2.ets @@ -0,0 +1,236 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 "deccjsunit/index"; +import featureAbility from "@ohos.ability.featureAbility"; +import wantConstant from '@ohos.ability.wantConstant'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' +import commonEvent from '@ohos.commonEvent'; + +export default function startAbilityTest2() { + + describe('startAbilityTest2', function () { + + var TAG = ""; + + var delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + beforeAll(async function (done) { + console.info("StartAbilityForResult before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityTest after each called"); + if ("FreeInstall_FA_Local_StartAbility_2000" === TAG) { + var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + } + + if ("FreeInstall_FA_Local_StartAbility_2500" === TAG) { + var cmd5 = "bm uninstall -n com.ohos.hag.famanager"; + delegator.executeShellCommand(cmd5, (err: any, d: any) => { + console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await sleep(500); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_1900 + * @tc.name The current service is not in the foreground. Page a jumps to page B first. + There are HAP packages that need not be installed under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_1900", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_1900-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_1900"; + let wrong; + var str1 = { + 'want': { + "bundleName": "com.open.harmony.startAbility", + "abilityName": "com.open.harmony.startAbility.PageAbility", + "moduleName": "entry", + } + } + featureAbility.startAbility(str1) + .then((data) => { + console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); + }) + await sleep(3000); + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(13); + console.info("------------end FreeInstall_FA_Local_StartAbility_1900-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_2000 + * @tc.name The current service is not in the foreground. Page a jumps to page B first. + The atomized HAP package has been installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_2000", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_2000-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_2000"; + var cmd2000 = "bm install -p data/test/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd2000, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let wrong; + var str1 = { + 'want': { + "bundleName": "com.open.harmony.startAbility", + "abilityName": "com.open.harmony.startAbility.PageAbility", + "moduleName": "entry", + } + } + featureAbility.startAbility(str1) + .then((data) => { + console.info(TAG + ' StartAbility successful. Promise Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); + }) + await sleep(3000); + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND + } + } + await featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(wrong.code).assertEqual(13); + console.info("------------end FreeInstall_FA_Local_StartAbility_2000-------------"); + await sleep(2000); + done(); + }); + + /* + * @tc.number FreeInstall_FA_Local_StartAbility_2500 + * @tc.name FA Service Center installation free timeout + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_FA_Local_StartAbility_2500", 0, async function (done) { + console.info("------------start FreeInstall_FA_Local_StartAbility_2500-------------"); + TAG = "FreeInstall_FA_Local_StartAbility_2500"; + var cmd2500 = "bm uninstall -n com.ohos.hag.famanager"; + delegator.executeShellCommand(cmd2500, (err: any, d: any) => { + console.info("executeShellCommand2500 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2501 = "bm install -p data/test/MockServiceTimeout.hap"; + delegator.executeShellCommand(cmd2501, (err: any, d: any) => { + console.info("executeShellCommand2501 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2502 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + delegator.executeShellCommand(cmd2502, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2503 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd2503, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2504 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps" + + "/entry/files"; + delegator.executeShellCommand(cmd2504, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + featureAbility.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + wrong = error; + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(35000); + expect(wrong.code).assertEqual(3); + console.info("------------end FreeInstall_FA_Local_StartAbility_2500-------------"); + done(); + }); + + console.info("-------------FA model--> startAbilityXTS Test end----------------") + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/Utils.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d9553a5c660be0a6ae524110f2dd4a6477abfd6 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,130 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } + + static getNowTime() { + return new Date().getTime(); + } + + static getDurationTime(log,startTime, endTime) { + console.info("Get Interface startTime: " + startTime); + console.info("Get Interface endTime: " + endTime); + var duration = (endTime - startTime); + console.info("Get Interface duration: " + duration); + return duration; + } +} + + + + diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/PageAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/PageAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7a6eb27919fa676345d20369d39aa6ef9b0b87f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/PageAbility/app.ets @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + console.info('Application onCreate') + setTimeout(function () { + featureAbility.terminateSelf() + .then((data) => { + console.info('PageAbility terminateself succeeded: ' + data); + }).catch((error) => { + console.error('PageAbility terminateself failed. Cause: ' + error); + }) + }, 8000); + }, + + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/PageAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/PageAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..315f8fd0f5e7062165ad23f4983489a34918b816 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/PageAbility/pages/index.ets @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2022 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 - PageAbility-B' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..19d075aee429cfdb5193cb801861ffbf17716543 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2022 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 particleAbility from '@ohos.ability.particleAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + + +var publishOptions = { + parameters: { + "assertData": "onSuccess" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service publish success!!!"); + } +} + +export default { + onStart() { + console.info('PAStartAbilityPromise001 ServiceAbility onStart'); + }, + onStop() { + console.info('PAStartAbilityPromise001 ServiceAbility onStop'); + }, + onCommand(want, startId) { + var str = { + 'want': { + 'deviceId': '', + 'bundleName': 'com.example.qianyiyingyong.hmservice', + 'abilityName': 'com.example.qianyiyingyong.ServiceAbility', + 'moduleName': 'entry', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + console.info('PAStartAbilityPromise001 ServiceAbility startAbility START' + JSON.stringify(str)); + particleAbility.startAbility(str) + .then((data) => { + console.info('FreeInstall_FA_Local_StartAbility_3700 ServiceAbility startAbility successful.' + + ' Data: ' + JSON.stringify(data)) + commonEvent.publish("service_event", publishOptions, PublishCallBack); + }).catch((error) => { + console.info('FreeInstall_FA_Local_StartAbility_3700 ServiceAbility startAbility failed. ' + + 'error: ' + JSON.stringify(error)); + }) + console.info('FreeInstall_FA_Local_StartAbility_3700 ServiceAbility startAbility END'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9e8ab66979f59c8109f65c8f2a4f21867fbf44b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e2674d1e6aaaad59b6fc2690508ee39564b4fd06 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "PageAbility_desc", + "value": "description" + }, + { + "name": "PageAbility_label", + "value": "label" + }, + { + "name": "ServiceAbility_desc", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/freeinstallstartabilityfatest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..93e0276d9f4aa1bbf25dc7ed73612e1150e97a0b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("StartAbilityNoTargetBundleListFaTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":startabilitynotargetbundlelistfatest_ets_assets", + ":startabilitynotargetbundlelistfatest_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "StartAbilityNoTargetBundleListFaTest" +} +ohos_js_assets("startabilitynotargetbundlelistfatest_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("startabilitynotargetbundlelistfatest_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/Test.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..7492f13e4af6dc4a96a3ffb644f201c300b141f4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/Test.json @@ -0,0 +1,34 @@ +{ + "description": "Configuration for startabilitynotargetbundlelistfatest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.open.harmony.startAbility", + "package-name": "com.open.harmony.startAbility", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "StartAbilityNoTargetBundleListFaTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "AtomizationFaEntry.hap -> /data/test/AtomizationFaEntry.hap", + "FaMyapplication1.hap -> /data/test/FaMyApplication1.hap", + "MockService.hap -> /data/test/MockService.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..9e0d55cc184ebced325cd195b9331128a6eaa16a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/config.json @@ -0,0 +1,116 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.open.harmony.startAbility", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "distro": { + "moduleType": "entry", + "installationFree": false, + "deliveryWithInstall": true, + "moduleName": "entry" + }, + "package": "com.open.harmony.startAbility", + "srcPath": "", + "name": ".entry", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".PageAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "reason": "need use ohos.permission.INSTALL_BUNDLE", + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.MANAGE_MISSIONS" + }, + { + "reason": "need use ohos.permission.INSTALL_BUNDLE", + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "reason": "need use ohos.permission.REMOVE_CACHE_FILES", + "name": "ohos.permission.REMOVE_CACHE_FILES" + }, + { + "reason": "need use ohos.permission.LISTEN_BUNDLE_CHANGE", + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..ea2b35a8c128f57ac266544e7b09a8b8578e5889 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,85 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 router from '@system.router'; +import file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend,expect} from "deccjsunit/index"; +import testsuite from "../test/List.test"; +import featureAbility from "@ohos.ability.featureAbility"; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + Want.parameters.timeout = 50000; + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text(' FA- StartAbility- NoTargetBundleList TEST ') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f3c0b2dbadb5f19ef98592192672ab452fa78530 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2022 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 StartAbilityTest from "./StartAbility.test"; + +export default function testsuite() { + StartAbilityTest(); + + +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/StartAbility.test.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/StartAbility.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2c70731d91551d55b06a53b62180b6c0ce070d9d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/StartAbility.test.ets @@ -0,0 +1,210 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 "deccjsunit/index"; +import Utils from './Utils'; +import featureAbility from "@ohos.ability.featureAbility"; +import wantConstant from '@ohos.ability.wantConstant'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +export default function StartAbilityTest() { + var TAG = ""; + + describe('StartAbilityTest', function () { + var delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + beforeAll(async function (done) { + console.info("StartAbilityTest before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd3 = "cp data/test/AtomizationFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityTest after each called"); + if ("FreeInstall_FA_StartAbility_2800" === TAG || "FreeInstall_FA_StartAbility_3900") { + var cmd5 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + delegator.executeShellCommand(cmd5, (err: any, d: any) => { + console.info("executeShellCommand5: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await Utils.sleep(500); + if ("FreeInstall_FA_StartAbility_3900" === TAG) { + var cmd4 = "bm uninstall -n com.ohos.hag.famanager"; + delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await Utils.sleep(500); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbility_2600 + * @tc.name: startAbility: NoTargetBundleList,free install successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbility_2600", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbility_2600-------------"); + TAG = "FreeInstall_FA_StartAbility_2600"; + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + expect(details).assertEqual(0); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbility_2700 + * @tc.name: startAbility: NoTargetBundleList and yuanzihua already installed,startAbility successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbility_2700", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbility_2700-------------"); + TAG = "FreeInstall_FA_StartAbility_2700"; + var cmd6 = "bm install -p data/test/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd6, (err: any, d: any) => { + console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + expect(details).assertEqual(0); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbility_2800 + * @tc.name: startAbility: The same application does not need to check targetbundlelist, + start feature hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbility_2800", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbility_2800-------------"); + TAG = "FreeInstall_FA_StartAbility_2800"; + var cmd7 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationFaEntry.hap"; + delegator.executeShellCommand(cmd7, (err: any, d: any) => { + console.info("executeShellCommand7 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd8 = "cp data/test/FaMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd8, (err: any, d: any) => { + console.info("executeShellCommand8 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.open.harmony.startAbility", + "abilityName": "com.example.myapplication1.MainAbility1", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + expect(details).assertEqual(0); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbility_3900 + * @tc.name: startAbility: The same application does not need to check targetbundlelist,add BACKGROUND flags + start feature hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbility_3900", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbility_3900-------------"); + TAG = "FreeInstall_FA_StartAbility_3900"; + let details; + var str = { + 'want': { + "bundleName": "com.open.harmony.startAbility", + "abilityName": "com.example.myapplication1.MainAbility1", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_WITH_BACKGROUND_MODE|wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbility(str).then((data) => { + details = data; + console.info(TAG + ' StartAbility successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbility failed. error: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + expect(details).assertEqual(0); + done(); + }); + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/Utils.ets b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..59a63137a97bfe99d8ea4933c0fba9ce7bcb0765 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,130 @@ +// @ts-nocheck +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } + + static getNowTime() { + return new Date().getTime(); + } + + static getDurationTime(log,startTime, endTime) { + console.info("Get Interface startTime: " + startTime); + console.info("Get Interface endTime: " + endTime); + var duration = (endTime - startTime); + console.info("Get Interface duration: " + duration); + return duration; + } +} + + + + diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9e8ab66979f59c8109f65c8f2a4f21867fbf44b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e9ceb262bf44ec47c3b68f991b633e3306ae00b4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "PageAbility_desc", + "value": "description" + }, + { + "name": "PageAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityfatest/startabilitynotargetbundlelistfatest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9294a07a450fc10dd33a9afb997ec44e506e6ec7 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationResultA") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":atomizationresulta_ets_assets", + ":atomizationresulta_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "AtomizationResultA" +} +ohos_js_assets("atomizationresulta_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("atomizationresulta_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..05f73cce051b1b6a832891a2a107525bb7cd4e6d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/config.json @@ -0,0 +1,73 @@ +{ + "app": { + "bundleName": "com.example.myapplicationA.hmserviceA", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplicationA", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": true + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..cb5b2ba7e6ae8c2c801ea5c1f47ee1db567f36b4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..71d9da1d9ceb041abd51816bc9009513fceb741e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..2feea323a55d9eb313203b69d8a0e048fe7c839b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8c525cd4c82a182536e34110ef41cb7f477a0cf1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "package_A" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a1.jpg b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..072898889d3562763186a082e59c7aace9979b70 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a1.jpg differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a2.jpg b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a2.jpg new file mode 100644 index 0000000000000000000000000000000000000000..072898889d3562763186a082e59c7aace9979b70 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a2.jpg differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a3.jpg b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a3.jpg new file mode 100644 index 0000000000000000000000000000000000000000..072898889d3562763186a082e59c7aace9979b70 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a3.jpg differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a4.jpg b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a4.jpg new file mode 100644 index 0000000000000000000000000000000000000000..072898889d3562763186a082e59c7aace9979b70 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/a4.jpg differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresulta/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9b26cf6966bb195426b4a7baa5c76ace7e6c744b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationResultFaEntry") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":atomizationresultfaentry_ets_assets", + ":atomizationresultfaentry_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "AtomizationResultFaEntry" +} +ohos_js_assets("atomizationresultfaentry_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("atomizationresultfaentry_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..ceaaeed30ef39694f4ef451d016a3e8130cc1339 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/config.json @@ -0,0 +1,83 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.qianyiyingyong", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": true + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + }, + { + "srcPath": "ServiceAbility", + "name": ".ServiceAbility", + "visible": true, + "icon": "$media:icon", + "srcLanguage": "ets", + "description": "$string:description_serviceability", + "type": "service" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second", + "pages/third" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..c3a2854faa2a78073ca79b7e4801ea1ba870ba84 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,59 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, + onStartContinuation() { + console.info('onStartContinuation'); + return true; + }, + + onActive(){ + console.info('onActive'); + setTimeout(function () { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "com.example.qianyiyingyong.hmservice.MainAbility", + }, + } + ); + featureAbility.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + }, 1000); + }, + + onRestoreData(data) { + console.info('onRestoreData' + data); + return true; + }, + onSaveData(data) { + console.info('onSaveData'); + return true; + }, + onCompleteContinuation(result) { + console.info('onCompleteContinuation:' + result); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/model/getRemoteDeviceModel.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/model/getRemoteDeviceModel.ets new file mode 100644 index 0000000000000000000000000000000000000000..1588ea0a222e06acd3076fc00e0dc3fb864ed0f3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/model/getRemoteDeviceModel.ets @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2022 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 deviceManager from '@ohos.distributedHardware.deviceManager'; + +var SUBSCRIBE_ID = 100; + +export default class RemoteDeviceModel { + deviceList = []; + deviceManager; + + constructor() { + } + + registerDeviceListCallback() { + if (typeof (this.deviceManager) === 'undefined') { + console.log('[dmsDemo] deviceManager.createDeviceManager begin'); + let self = this; + deviceManager.createDeviceManager('com.ohos.distributedmusicplayer', (error, value) => { + if (error) { + console.error('createDeviceManager failed.'); + return; + } + self.deviceManager = value; + self.registerDeviceListCallback_(); + console.log('[dmsDemo] createDeviceManager callback returned, error=' + error + ' value=' + JSON.stringify(value)); + }); + console.log('[dmsDemo] deviceManager.createDeviceManager end'); + } else { + this.registerDeviceListCallback_(); + } + } + + registerDeviceListCallback_(){ + console.info('[dmsDemo] registerDeviceListCallback'); + if (this.deviceManager == undefined) { + console.error('[dmsDemo] deviceManager has not initialized'); + return; + } + + console.info('[dmsDemo] getTrustedDeviceListSync begin'); + var list = this.deviceManager.getTrustedDeviceListSync(); + console.info('[dmsDemo] getTrustedDeviceListSync end, deviceList=' + JSON.stringify(list)); + if (typeof (list) != 'undefined' && typeof (list.length) != 'undefined') { + this.deviceList = list; + } + console.info('[dmsDemo] callback finished'); + } + + unregisterDeviceListCallback() { + console.info('[dmsDemo] stopDeviceDiscovery ' + SUBSCRIBE_ID); + this.deviceManager.stopDeviceDiscovery(SUBSCRIBE_ID); + this.deviceList = []; + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fd1a883f117c534c3b33e5505307666ecb98837e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,102 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; +import featureAbility from '@ohos.ability.featureAbility' + +async function routePage(uri) { + let options = { + uri: uri + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page1') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage('pages/second') + }) + + Button() { + Text('同应用不需要检查targetbundlelist名单') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage('pages/third') + }) + + Button() { + Text('StartAbilityForResult') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + this.terminateSelfWithResult(); + }) + } + .width('100%') + .height('100%') + } + + async terminateSelfWithResult() { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + await featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "com.example.qianyiyingyong.MainAbility", + }, + } + ); + await featureAbility.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..9dcd951896be78626c21d48cf64296d4194f8a81 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/third.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/third.ets new file mode 100644 index 0000000000000000000000000000000000000000..5cfba1b1abc9b4b0e61c8e87f423ff6c86cbb66d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/MainAbility/pages/third.ets @@ -0,0 +1,343 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; +import featureAbility from '@ohos.ability.featureAbility'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; +import RemoteDeviceModel from '../model/getRemoteDeviceModel.ets'; +import bundleManager from '@ohos.bundle'; + +const BUNDLE_NAME = 'com.example.qianyiyingyong.hmservice'; +const ABILITY_NAME = 'com.example.qianyiyingyong.MainAbility'; +const ABILITY_NAME1 = 'com.example.hm2.MainAbility'; +const ABILITY_NAME2 = 'com.example.hm3.MainAbility'; + +let remoteDeviceId = ''; +let remoteDeviceModel = null; + +@Entry +@Component +struct Third { + private content: string = "Third Page" + private contextText: string= ''; + private localDeviceId: string= ''; + private backgroundColor = Color.Grey; + private tipsMsg = '请输入对端的deviceId'; + private isOn = false; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold); + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold); + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back(); + }); + Row() { + Text('关闭是startAbility,打开是startAbilityForResult:') + .fontSize(20) + .fontWeight(FontWeight.Bold); + + Toggle({ type: ToggleType.Switch, isOn: this.isOn }) + .width($r('app.float.wh_value_50')) + .height($r('app.float.wh_value_40')) + .onChange((isOn) => { + console.info('startAbility fAStartAbilityPromise isOn:' + isOn); + this.isOn = isOn; + console.info('startAbility fAStartAbilityPromise this.isOn:' + this.isOn); + }); + } + .margin({ right: $r('app.float.wh_value_15') }) + .align(Alignment.End); + TextInput({ placeholder: '请输入deviceId', text: this.contextText }) + .placeholderColor(Color.Blue) + .placeholderFont({ + size: $r('app.float.wh_value_20'), + weight: 2, + family: "sans-serif", + style: FontStyle.Normal + }) + .caretColor(Color.Blue) + .height($r('app.float.wh_value_70')) + .backgroundColor(Color.White) + .type(InputType.Normal) + .width('100%') + .fontStyle(FontStyle.Italic) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) + .onChange((value: string) => { + this.contextText = value; + }); + + Text('fAStartAbilityPromiseSameBundleName001 本设备,本应用不同AbilityName') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + if (this.isOn) { + this.fAStartAbilityForResultPromise('fAStartAbilityPromiseSameBundleName001', str); + } else { + this.fAStartAbilityPromise('fAStartAbilityPromiseSameBundleName001', str); + } + }); + + Text('fAStartAbilityPromiseSameBundleName005 entry覆盖安装') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + this.fAStartAbilityPromise('fAStartAbilityPromiseSameBundleName005', str); + }); + + Text('fAStartAbilityPromiseSameBundleName006 在免安装更新的时候需先设置updateModuleUpgradeFlag') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + this.updateModuleUpgradeFlag('fAStartAbilityPromiseSameBundleName006','entry'); + }); + + Text('fAStartAbilityPromiseSameBundleNameKSB002 跨设备,同应用不同AbilityName') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + if ('' === remoteDeviceId && '' === this.contextText) { + this.tips(this.tipsMsg); + return; + } + var str = { + 'want': { + 'deviceId': '' === this.contextText ? remoteDeviceId : this.contextText, + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + if (this.isOn) { + this.fAStartAbilityForResultPromise('fAStartAbilityPromiseSameBundleNameKSB002', str); + } else { + this.fAStartAbilityPromise('fAStartAbilityPromiseSameBundleNameKSB002', str); + } + }); + + Text('fAStartAbilityPromiseSameBundleNameKSB003 跨设备,同应用,对端FA的visable为false无法拉起') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + if ('' === remoteDeviceId && '' === this.contextText) { + this.tips(this.tipsMsg); + return; + } + var str = { + 'want': { + 'deviceId': '' === this.contextText ? remoteDeviceId : this.contextText, + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME2, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + if (this.isOn) { + this.fAStartAbilityForResultPromise('fAStartAbilityPromiseSameBundleNameKSB003', str); + } else { + this.fAStartAbilityPromise('fAStartAbilityPromiseSameBundleNameKSB003', str); + } + }); + + Text('fAStartAbilityPromiseSameBundleName004 跨设备,同应用不同AbilityName,无跨设备权限(拉起应用或被拉起应用)') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + if (this.isOn) { + this.fAStartAbilityForResultPromise('fAStartAbilityPromiseSameBundleName004', str); + } else { + this.fAStartAbilityPromise('fAStartAbilityPromiseSameBundleName004', str); + } + }); + } + .width('100%') + .height('100%') + } + + async updateModuleUpgradeFlag(tag, type1) { + console.info(tag + ' startAbility fAStartAbilityPromise START' + JSON.stringify(type1)); + await bundleManager.setModuleUpgradeFlag("com.example.qianyiyingyong.hmservice",type1,1); + console.info(tag + ' startAbility fAStartAbilityPromise END'); + } + + async fAStartAbilityPromise(tag, str) { + console.info(tag + ' startAbility fAStartAbilityPromise START' + JSON.stringify(str)); + let code; + await featureAbility.startAbility(str) + .then((data) => { + console.info(tag + ' startAbility Operation successful. Promise Data: ' + JSON.stringify(data)) + code = data; + }).catch((error) => { + console.info(tag + ' startAbility Operation failed. Promise Cause: ' + JSON.stringify(error)); + code = error; + }) + console.info(tag + ' startAbility Operation code Promise: ' + JSON.stringify(code)); + if (code === 0) { + this.tips('成功'); + } else { + this.tips('错误码:' + code.code); + } + console.info(tag + ' startAbility fAStartAbilityPromise END'); + } + + async fAStartAbilityCallBack(tag, str) { + let code; + console.info(tag + 'startAbility fAStartAbilityCallBack START' + JSON.stringify(str)); + featureAbility.startAbility(str, (err, data) => { + code = data; + if (err) { + console.error(tag + ' Operation failed. CallBack Cause:' + JSON.stringify(err)); + code = err; + } + if (code === 0) { + this.tips('成功'); + } else { + this.tips('错误码:' + code.code); + } + console.info('Operation successful. CallBack Data: ' + JSON.stringify(data)) + }); + console.info(tag + 'startAbility fAStartAbilityCallBack END'); + } + + async fAStartAbilityForResultPromise(tag, str) { + console.info(tag + ' fAStartAbilityForResultPromise START' + JSON.stringify(str)); + let newData; + await featureAbility.startAbilityForResult(str) + .then((data) => { + this.tips('成功'); + newData = data; + console.info(tag + ' fAStartAbilityForResultPromise Operation successful. Promise Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(tag + ' fAStartAbilityForResultPromise Operation failed. Promise Cause: ' + JSON.stringify(error)); + newData = error; + this.tips('失败'); + }) + console.info(tag + ' fAStartAbilityForResultPromise Operation newData Promise: ' + JSON.stringify(newData)); + console.info(tag + ' fAStartAbilityForResultPromise fAStartAbilityPromise END'); + } + + async fAStartAbilityForResultCallBack(tag, str) { + console.info(tag + 'fAStartAbilityForResultCallBack START' + JSON.stringify(str)); + featureAbility.startAbilityForResult(str, (err, data) => { + console.info(tag + 'fAStartAbilityForResultCallBack Operation CallBack Data: ' + JSON.stringify(data)) + if (err) { + this.tips('失败'); + console.info(tag + 'fAStartAbilityForResultCallBack Operation CallBack err:' + JSON.stringify(err)); + return; + } + this.tips('成功'); + }); + console.info(tag + 'fAStartAbilityForResultCallBack END'); + } + + tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } + + onBackPress() { + console.log('[startAbility] get device onBackPress in'); + this.contextText = ''; + console.log('[startAbility] get device onBackPress out'); + } + + private aboutToAppear(): void { + console.info('[startAbility] aboutToAppear in'); + remoteDeviceModel = new RemoteDeviceModel; + remoteDeviceModel.registerDeviceListCallback(); + console.info('[startAbility] aboutToAppear end'); + } + + onPageShow(): void{ + console.info('[startAbility] onPageShow in'); + let numDevices = remoteDeviceModel.deviceList.length; + if (numDevices === 0) { + this.tips('onStartRemoteAbility no device found') + return; + } + remoteDeviceId = remoteDeviceModel.deviceList[0].deviceId; + console.info('[startAbility] onPageShow deviceId is ' + remoteDeviceId); + } + + private aboutToDisappear() { + console.info('[startAbility] aboutToDisappear in'); + remoteDeviceModel.unregisterDeviceListCallback(); + console.info('[startAbility] aboutToDisappear out'); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/ServiceAbility/service.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/ServiceAbility/service.ts new file mode 100644 index 0000000000000000000000000000000000000000..e854039d4d655bbf23cb12a5a675f34d0a733c3e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/ets/ServiceAbility/service.ts @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export default { + onStart() { + console.info('qianyiyingyong ServiceAbility onStart'); + }, + onStop() { + console.info('qianyiyingyong ServiceAbility onStop'); + }, + onCommand(want, startId) { + console.info('qianyiyingyong ServiceAbility onCommand'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/element/float.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..6f8d0c2063b868636f443046d8d777b0c4e3ab3f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/element/float.json @@ -0,0 +1,124 @@ +{ + "float": [ + { + "name": "wh_value_1", + "value": "1" + }, + { + "name": "wh_value_5", + "value": "5" + }, + { + "name": "wh_value_10", + "value": "10" + }, + { + "name": "wh_value_15", + "value": "15" + }, + { + "name": "wh_value_20", + "value": "20" + }, + { + "name": "wh_value_30", + "value": "30" + }, + { + "name": "wh_value_40", + "value": "40" + }, + { + "name": "wh_value_50", + "value": "50" + }, + { + "name": "wh_value_60", + "value": "60" + }, + { + "name": "wh_value_65", + "value": "65" + }, + { + "name": "wh_value_70", + "value": "70" + }, + { + "name": "wh_value_80", + "value": "80" + }, + { + "name": "wh_value_100", + "value": "100" + }, + { + "name": "wh_value_130", + "value": "1300" + }, + { + "name": "wh_value_160", + "value": "160" + }, + { + "name": "wh_value_230", + "value": "230" + }, + { + "name": "wh_value_280", + "value": "280" + }, + { + "name": "wh_value_390", + "value": "390" + }, + { + "name": "wh_value_400", + "value": "400" + }, + { + "name": "font_35", + "value": "35" + }, + { + "name": "font_18", + "value": "18" + }, + { + "name": "font_20", + "value": "20" + }, + { + "name": "font_21", + "value": "21" + }, + { + "name": "font_22", + "value": "22" + }, + { + "name": "font_24", + "value": "24" + }, + { + "name": "font_28", + "value": "28" + }, + { + "name": "font_50", + "value": "50" + }, + { + "name": "control_common_font_size", + "value": "20" + }, + { + "name": "slider_text_padding_left", + "value": "5" + }, + { + "name": "volume_border_radius", + "value": "15" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0532654394e0ffa53b6d6ea673a420da69d921e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "迁移111" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "description_serviceability", + "value": "hap sample empty service" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfaentry/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..39d88508900cfc190365b679893785216bb47b4e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationResultFaHm1") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":atomizationresultfahm1_ets_assets", + ":atomizationresultfahm1_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "AtomizationResultFaHm1" +} +ohos_js_assets("atomizationresultfahm1_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("atomizationresultfahm1_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..1befc4efe23c420b3d387e25d08419cb70faa2af --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/config.json @@ -0,0 +1,63 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.qianyiyingyong", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "hm1", + "moduleType": "feature", + "installationFree": true + }, + "abilities": [ + { + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:hm1_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..881d9152e264e8415299fdcab1052e1f68f9ce73 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + console.info('Application onCreate') + }, + + onActive(){ + console.info('onActive'); + setTimeout(function () { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "com.example.hm2.MainAbility", + }, + } + ); + featureAbility.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + }, 1000); + }, + + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2bff6de731d4ac935e8ce06a86c4418fd680ece9 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,88 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; +import featureAbility from '@ohos.ability.featureAbility' + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + + Button() { + Text('StartAbilityForResult') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + this.terminateSelfWithResult(); + }) + } + .width('100%') + .height('100%') + } +async terminateSelfWithResult() { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + await featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "com.example.qianyiyingyong.MainAbility", + }, + } + ); + await featureAbility.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..9dcd951896be78626c21d48cf64296d4194f8a81 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..cbf235aa4f985fb9995c84c837dc5d50ab6bc014 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "hm1_MainAbility", + "value": "相同BN和AN" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm1/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..5f9a7981cc583665d1f6de8815dbe70b70a6a9a4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationResultFaHm2") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":atomizationresultfahm2_ets_assets", + ":atomizationresultfahm2_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "AtomizationResultFaHm2" +} +ohos_js_assets("atomizationresultfahm2_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("atomizationresultfahm2_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..225b1a21bb7dd12153bde34267da643de1377398 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/config.json @@ -0,0 +1,63 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.hm2", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "hnm2", + "moduleType": "feature", + "installationFree": true + }, + "abilities": [ + { + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:description_mainability", + "formsEnabled": false, + "label": "$string:hnm2_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index", + "pages/second" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..881d9152e264e8415299fdcab1052e1f68f9ce73 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + console.info('Application onCreate') + }, + + onActive(){ + console.info('onActive'); + setTimeout(function () { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "com.example.hm2.MainAbility", + }, + } + ); + featureAbility.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + }, 1000); + }, + + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a5fc0ea8f5d00a1b74788cce8eb03ec7b88e9a74 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,145 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; +import featureAbility from '@ohos.ability.featureAbility' +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; + +const BUNDLE_NAME = 'com.example.qianyiyingyong.hmservice'; +const ABILITY_NAME1 = 'com.example.hm2.MainAbility'; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + + private backgroundColor = Color.Grey; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('HNM2 next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + + Text('fAStartAbilityPromiseSameBundleName1 本设备,feature覆盖安装') + .height(70) + .width('100%') + .fontSize(20) + .fontColor(Color.White) + .fontWeight(FontWeight.Bold) + .margin({ top: 20 }) + .backgroundColor(this.backgroundColor) + .onClick(() => { + var str = { + 'want': { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + }; + this.fAStartAbilityPromise('fAStartAbilityPromiseSameBundleName1', str); + + }); + + Button() { + Text('StartAbilityForResult') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + this.terminateSelfWithResult(); + }) + } + .width('100%') + .height('100%') + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + featureAbility.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } + + async terminateSelfWithResult() { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + await featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "com.example.hm2.MainAbility", + }, + } + ); + await featureAbility.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + } + + async fAStartAbilityPromise(tag, str) { + console.info(tag + ' startAbility fAStartAbilityPromise START' + JSON.stringify(str)); + let code; + await featureAbility.startAbility(str) + .then((data) => { + console.info(tag + ' startAbility Operation successful. Promise Data: ' + JSON.stringify(data)) + code = data; + }).catch((error) => { + console.info(tag + ' startAbility Operation failed. Promise Cause: ' + JSON.stringify(error)); + code = error; + }) + console.info(tag + ' startAbility Operation code Promise: ' + JSON.stringify(code)); + if (code === 0) { + this.tips('成功'); + } else { + this.tips('错误码:' + code.code); + } + console.info(tag + ' startAbility fAStartAbilityPromise END'); + } + + tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e0296ed6e5ec446039002974e449266f2ed14f4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/ets/MainAbility/pages/second.ets @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2022 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 router from '@system.router'; + +@Entry +@Component +struct Second { + private content: string = "HNM2 Second Page" + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text(`${this.content}`) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('back to index') + .fontSize(20) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + router.back() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8380229de102511d01d094185835cbe3c975d9d8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/resources/base/element/string.json @@ -0,0 +1,12 @@ +{ + "string": [ + { + "name": "hnm2_MainAbility", + "value": "相同BN不同AN" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/atomizationresultfahm2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9031dbe8a87b1ce2d4465e9ff5d5916f0661d38b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FaResultMyApplication1") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":faresultmyapplication1_ets_assets", + ":faresultmyapplication1_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FaResultMyApplication1" +} +ohos_js_assets("faresultmyapplication1_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("faresultmyapplication1_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d9fdcb92f81eac53bf51c78a428be0210c192b89 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests" +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..2f51d1544830ffc0a58e73c23885676e0a2a3e75 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/config.json @@ -0,0 +1,73 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.open.harmony.startAbilityForResult", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility1", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility1", + "name": ".MainAbility1", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility1_desc", + "formsEnabled": false, + "label": "$string:MainAbility1_label", + "type": "page", + "launchType": "standard" + } + ], + "distro": { + "moduleType": "feature", + "installationFree": true, + "deliveryWithInstall": true, + "moduleName": "myapplication1" + }, + "package": "com.example.myapplication1", + "srcPath": "", + "name": ".myapplication1", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility1", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..15d6b37d6a7f89f4e76db0180c838725ab29467d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,45 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + console.info('Application onCreate') + }, + + onActive(){ + console.info('onActive'); + setTimeout(function () { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + featureAbility.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.open.harmony.startAbilityForResult", + abilityName: "com.open.harmony.startAbilityForResult.MainAbility1", + }, + } + ); + featureAbility.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + }, 1000); + }, + + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb5ac58410e01463816bf3127d933e4ebef5376c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 = 'Same app - not need to check targetbundlelist' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0ab9f9b1dcb2df0331476e1ae3619426cf2b3b47 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "myapplication1_desc", + "value": "description" + }, + { + "name": "MainAbility1_desc", + "value": "description" + }, + { + "name": "MainAbility1_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/faresultmyapplication1/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b3f3f8a5ff3c3781604897540136b84c1ec3b5ba --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FreeInstallStartAbilityForResultFaTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":freeinstallstartabilityforresultfatest_ets_assets", + ":freeinstallstartabilityforresultfatest_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "FreeInstallStartAbilityForResultFaTest" +} +ohos_js_assets("freeinstallstartabilityforresultfatest_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("freeinstallstartabilityforresultfatest_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..d78670e9c553fa0c3028d9310d1eb8111a6f2096 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/Test.json @@ -0,0 +1,37 @@ +{ + "description": "Configuration for freeinstallstartabilityforresultfatest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.open.harmony.startAbilityForResult", + "package-name": "com.open.harmony.startAbilityForResult", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "FreeInstallStartAbilityForResultFaTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "AtomizationResultFaEntry.hap -> /data/test/AtomizationResultFaEntry.hap", + "AtomizationResultFaHm1.hap -> /data/test/AtomizationResultFaHm1.hap", + "AtomizationResultFaHm2.hap -> /data/test/AtomizationResultFaHm2.hap", + "MockService.hap -> /data/test/MockService.hap", + "MockServiceTimeout.hap -> /data/test/MockServiceTimeout.hap", + "AtomizationResultA.hap -> /data/test/AtomizationResultA.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..acdffda30fa4546cc034ff80b0364f472fecb598 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/config.json @@ -0,0 +1,131 @@ +{ + "app": { + "targetBundleList": [ + "com.example.qianyiyingyong.hmservice" + ], + "vendor": "example", + "bundleName": "com.open.harmony.startAbilityForResult", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + }, + { + "orientation": "unspecified", + "srcPath": "PageAbility", + "name": ".PageAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:PageAbility_desc", + "formsEnabled": false, + "label": "$string:PageAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "distro": { + "moduleType": "entry", + "installationFree": false, + "deliveryWithInstall": true, + "moduleName": "entry" + }, + "package": "com.open.harmony.startAbilityForResult", + "srcPath": "", + "name": ".entry", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".PageAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "reason": "need use ohos.permission.INSTALL_BUNDLE", + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.MANAGE_MISSIONS" + }, + { + "reason": "need use ohos.permission.INSTALL_BUNDLE", + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "reason": "need use ohos.permission.REMOVE_CACHE_FILES", + "name": "ohos.permission.REMOVE_CACHE_FILES" + }, + { + "reason": "need use ohos.permission.LISTEN_BUNDLE_CHANGE", + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..bfec465ee4537e893285030f9b1113f3b6272376 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,85 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 router from '@system.router'; +import file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend,expect} from "deccjsunit/index"; +import testsuite from "../test/List.test"; +import featureAbility from "@ohos.ability.featureAbility"; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + Want.parameters.timeout = 50000; + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text(' FA- StartAbilityForResult TEST ') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..e1ceebca9a6898ac11814ec075264d49d1c30240 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 StartAbilityForResult from "./StartAbilityForResult.test"; +import StartAbilityForResult2 from "./StartAbilityForResult2.test"; + +export default function testsuite() { + StartAbilityForResult(); + StartAbilityForResult2(); + +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult.test.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..660389022af82768af49639c62bd9e58fd1f5cbd --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult.test.ets @@ -0,0 +1,973 @@ +// @ts-nocheck + + +/** + * Copyright (c) 2022 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 "deccjsunit/index"; +import Utils from './Utils'; +import featureAbility from "@ohos.ability.featureAbility"; +import wantConstant from '@ohos.ability.wantConstant'; +import abilityManager from '@ohos.application.abilityManager'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +export default function StartAbilityForResult() { + var TAG = ""; + var DeviceId = ""; + + + describe('StartAbilityForResult', function () { + var delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + beforeAll(async function (done) { + console.info("StartAbilityForResult before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps" + + "/entry/files"; + delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityForResult after each called"); + if ("FreeInstall_FA_StartAbilityForResult_0100" === TAG || + "FreeInstall_FA_StartAbilityForResult_0400" === TAG || + "FreeInstall_FA_StartAbilityForResult_0700" === TAG || + "FreeInstall_FA_StartAbilityForResult_1000" === TAG || + "FreeInstall_FA_StartAbilityForResult_1100" === TAG || + "FreeInstall_FA_StartAbilityForResult_1400" === TAG || + "FreeInstall_FA_StartAbilityForResult_1600" === TAG || + "FreeInstall_FA_StartAbilityForResult_1900" === TAG || + "FreeInstall_FA_StartAbilityForResult_2100" === TAG || + "FreeInstall_FA_StartAbilityForResult_3000" === TAG || + "FreeInstall_FA_StartAbilityForResult_3100" === TAG) { + var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + } + + if ("FreeInstall_FA_StartAbilityForResult_3200" === TAG) { + var cmd14 = "bm uninstall -n com.ohos.hag.famanager"; + delegator.executeShellCommand(cmd14, (err: any, d: any) => { + console.info("executeShellCommand14: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd26 = "bm uninstall -n com.example.myapplicationA.hmserviceA"; + delegator.executeShellCommand(cmd26, (err: any, d: any) => { + console.info("executeShellCommand26: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await Utils.sleep(500); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0100 + * @tc.name: startAbilityForResult: Input empty deviceId,free install and start successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0100", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0100-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0100"; + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0200 + * @tc.name: startAbilityForResult: Send wrong yuanzihua under the path + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0200", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0200-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0200"; + var cmd15 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd15, (err: any, d: any) => { + console.info("executeShellCommand15: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd16 = "cp data/test/AtomizationResultA.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd16, (err: any, d: any) => { + console.info("executeShellCommand16: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let wrong; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + expect(wrong.code).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0300 + * @tc.name: startAbilityForResult: Remove the yuanzihua under the path + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0300", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0300-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0300"; + var cmd17 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultA.hap"; + delegator.executeShellCommand(cmd17, (err: any, d: any) => { + console.info("executeShellCommand17: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let wrong; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + expect(wrong.code).assertEqual(4); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0400 + * @tc.name: startAbilityForResult: Free install and start successfully (add abilityStartSetting). + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0400", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0400-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0400"; + var cmd18 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd18, (err: any, d: any) => { + console.info("executeShellCommand18: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0500 + * @tc.name: startAbilityForResult: Send wrong yuanzihua under the path (add abilityStartSetting). + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0500", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0500-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0500"; + var cmd15 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd15, (err: any, d: any) => { + console.info("executeShellCommand15: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd16 = "cp data/test/AtomizationResultA.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd16, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let wrong; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + expect(wrong.code).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0600 + * @tc.name: startAbilityForResult: Remove the yuanzihua under the path (add abilityStartSetting). + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0600", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0600-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0600"; + var cmd17 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultA.hap"; + delegator.executeShellCommand(cmd17, (err: any, d: any) => { + console.info("executeShellCommand17: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let wrong; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + expect(wrong.code).assertEqual(4); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0700 + * @tc.name: startAbilityForResult: No deviceId,free install and start successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0700", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0700-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0700"; + var cmd18 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd18, (err: any, d: any) => { + console.info("executeShellCommand18: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(1000); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0800 + * @tc.name: startAbilityForResult: No deviceId,free install and start successfully (add abilityStartSetting). + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0800", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0800-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0800"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_0900 + * @tc.name: startAbilityForResult: yuanzihua already installed,start successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_0900", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_0900-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_0900"; + var cmd900 = "bm install -p data/test/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd900, (err: any, d: any) => { + console.info("executeShellCommand900: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(1000); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1000 + * @tc.name: startAbilityForResult: yuanzihua already installed,start successfully (add abilityStartSetting). + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1000", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1000-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1000"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1100 + * @tc.name: startAbilityForResult: Input local deviceId,free install and start successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1100", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1100-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1100"; + let details1; + let details2; + await abilityManager.getTopAbility().then((data) => { + details1 = data; + console.info(' getTopAbility succeeded data: ' + JSON.stringify(data)); + }).catch((error) => { + console.error(' getTopAbility error: ' + JSON.stringify(error)); + }); + console.log(" checkAbilityInfo deviceId : " + details1.ability.deviceId); + DeviceId = details1.ability.deviceId; + await Utils.sleep(500); + var str = { + 'want': { + "deviceId": DeviceId, + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details2 = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details2.resultCode); + expect(details2.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1200 + * @tc.name: startAbilityForResult: Input local deviceId, add abilityStartSetting. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1200", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1200-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1200"; + let details1; + let details2; + await abilityManager.getTopAbility().then((data) => { + details1 = data; + console.info(' getTopAbility succeeded data: ' + JSON.stringify(data)); + }).catch((error) => { + console.error(' getTopAbility error: ' + JSON.stringify(error)); + }); + console.log(" checkAbilityInfo deviceId : " + details1.ability.deviceId); + DeviceId = details1.ability.deviceId; + await Utils.sleep(1000); + var str = { + 'want': { + "deviceId": DeviceId, + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details2 = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details2.resultCode); + expect(details2.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1300 + * @tc.name: startAbilityForResult: Free install feature hap and start successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1300", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1300-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1300"; + var cmd7 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd7, (err: any, d: any) => { + console.info("executeShellCommand7: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd8 = "cp data/test/AtomizationResultFaHm2.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd8, (err: any, d: any) => { + console.info("executeShellCommand8: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hnm2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(3000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1400 + * @tc.name: startAbilityForResult: start feature hap successfully (add abilityStartSetting). + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1400", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1400-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1400"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hnm2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1500 + * @tc.name: startAbilityForResult: Call by AsyncCallback. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1500", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1500-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1500"; + var cmd1500 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultFaHm2.hap"; + delegator.executeShellCommand(cmd1500, (err: any, d: any) => { + console.info("executeShellCommand1500: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(1000); + var cmd1501 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + delegator.executeShellCommand(cmd1501, (err: any, d: any) => { + console.info("executeShellCommand1501: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(1000); + let details; + var str = { + 'want': { + "bundleName": 'com.example.qianyiyingyong.hmservice', + "abilityName": 'com.example.qianyiyingyong.MainAbility', + "moduleName": 'entry', + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str, (err, data) => { + console.info(TAG + ": StartAbilityForResultCallBack success, err: " + JSON.stringify(err) + + ",data: " + JSON.stringify(data)); + details = data.resultCode; + }) + setTimeout(function () { + console.info(TAG + " resultCode: " + details); + expect(details).assertEqual(1); + done(); + }, 4000); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1600 + * @tc.name: startAbilityForResult: Call by AsyncCallback (add abilityStartSetting). + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1600", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1600-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1600"; + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + }, + 'abilityStartSetting': { + "key": "test:let your heart guide you!" + } + } + await featureAbility.startAbilityForResult(str, (err, data) => { + console.info(TAG + ": StartAbilityForResultCallBack success, err: " + JSON.stringify(err) + + ",data: " + JSON.stringify(data)); + details = data.resultCode; + }) + setTimeout(function () { + console.info(TAG + " resultCode: " + details); + expect(details).assertEqual(1); + done(); + }, 4000); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1700 + * @tc.name: startAbilityForResult: Input wrong flags(22),free install failed. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1700", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1700-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1700"; + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': 22 + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + expect(wrong.code).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1800 + * @tc.name: startAbilityForResult: Input wrong flags('11'),free install failed. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1800", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1800-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1800"; + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': '11' + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + expect(wrong.code).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_1900 + * @tc.name: startAbilityForResult: yuanzihua already installed,input wrong flags('11'),start successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_1900", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_1900-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_1900"; + var cmd19 = "bm install -p data/test/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd19, (err: any, d: any) => { + console.info("executeShellCommand19: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd1901 = "bm install -p data/test/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd1901, (err: any, d: any) => { + console.info("executeShellCommand1901: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': '11' + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_2000 + * @tc.name: startAbilityForResult: Input empty flags,free install failed. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_2000", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_2000-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_2000"; + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': '' + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + expect(wrong.code).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_2100 + * @tc.name: startAbilityForResult: yuanzihua already installed,input empty flags,start successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_2100", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_2100-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_2100"; + var cmd19 = "bm install -p data/test/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd19, (err: any, d: any) => { + console.info("executeShellCommand19: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(1000); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': '' + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_3000 + * @tc.name: startAbilityForResult: Input different moduleName(feature hap),start feature hap. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_3000", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_3000-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_3000"; + var cmd9 = "bm install -p data/test/AtomizationResultFaHm1.hap"; + delegator.executeShellCommand(cmd9, (err: any, d: any) => { + console.info("executeShellCommand9 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "hm1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_3100 + * @tc.name: startAbilityForResult: Input parameters extended information,free install and start successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_3100", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_3100-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_3100"; + let details; + var str = { + 'want': { + 'deviceId': '', + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + 'parameters': { + "name": "1111", "Ext2": "ExtValue2", "site": "很开心看到你!" + } + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_3200 + * @tc.name: startAbilityForResult: Input wrong moduleName(“xxxxx”), free install failed. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_3200", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_3200-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_3200"; + let wrong; + var str = { + 'want': { + 'deviceId': '', + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "xxxxx", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + expect(wrong.code).assertEqual(1); + done(); + }); + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult2.test.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult2.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..176ca0d7e692cc4e71f98e5136601d55b332c7f1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult2.test.ets @@ -0,0 +1,227 @@ +// @ts-nocheck + + +/** + * Copyright (c) 2022 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 "deccjsunit/index"; +import Utils from './Utils'; +import featureAbility from "@ohos.ability.featureAbility"; +import wantConstant from '@ohos.ability.wantConstant'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +export default function StartAbilityForResult2() { + var TAG = ""; + + describe('StartAbilityForResult2', function () { + var delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + beforeAll(async function (done) { + console.info("StartAbilityForResult before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityForResult after each called"); + if ("FreeInstall_FA_StartAbilityForResult_2300" === TAG) { + var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + } + + if ("FreeInstall_FA_StartAbilityForResult_2600" === TAG) { + var cmd14 = "bm uninstall -n com.ohos.hag.famanager"; + delegator.executeShellCommand(cmd14, (err: any, d: any) => { + console.info("executeShellCommand14: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await Utils.sleep(500); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_2200 + * @tc.name: startAbilityForResult: The page A not in the foreground. Page A jumps to page B first. + The atomized HAP package has not been installed. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_2200", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_2200-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_2200"; + var str1 = { + 'want': { + "bundleName": "com.open.harmony.startAbilityForResult", + "abilityName": "com.open.harmony.startAbilityForResult.PageAbility", + "moduleName": "entry", + } + } + featureAbility.startAbilityForResult(str1) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(3000); + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + expect(wrong.code).assertEqual(13); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_2300 + * @tc.name: startAbilityForResult: The page A not in the foreground. Page A jumps to page B first. + The atomized HAP package has been installed. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_2300", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_2300-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_2300"; + var cmd19 = "bm install -p data/test/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd19, (err: any, d: any) => { + console.info("executeShellCommand19: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var str1 = { + 'want': { + "bundleName": "com.open.harmony.startAbilityForResult", + "abilityName": "com.open.harmony.startAbilityForResult.PageAbility", + "moduleName": "entry", + } + } + featureAbility.startAbilityForResult(str1) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(3000); + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + expect(wrong.code).assertEqual(13); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_2600 + * @tc.name: startAbilityForResult: Free install timeout 30s. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_2600", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_2600-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_2600"; + var cmd20 = "bm uninstall -n com.ohos.hag.famanager"; + delegator.executeShellCommand(cmd20, (err: any, d: any) => { + console.info("executeShellCommand20: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd21 = "bm install -p data/test/MockServiceTimeout.hap"; + delegator.executeShellCommand(cmd21, (err: any, d: any) => { + console.info("executeShellCommand21: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let wrong; + var str = { + 'want': { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + featureAbility.startAbilityForResult(str) + .then((data) => { + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + wrong = error; + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await Utils.sleep(35000); + expect(wrong.code).assertEqual(13); + done(); + }); + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/Utils.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..4d9553a5c660be0a6ae524110f2dd4a6477abfd6 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,130 @@ +// @ts-nocheck +/** + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } + + static getNowTime() { + return new Date().getTime(); + } + + static getDurationTime(log,startTime, endTime) { + console.info("Get Interface startTime: " + startTime); + console.info("Get Interface endTime: " + endTime); + var duration = (endTime - startTime); + console.info("Get Interface duration: " + duration); + return duration; + } +} + + + + diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/PageAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/PageAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..f7a6eb27919fa676345d20369d39aa6ef9b0b87f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/PageAbility/app.ets @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import featureAbility from '@ohos.ability.featureAbility'; + +export default { + onCreate() { + console.info('Application onCreate') + setTimeout(function () { + featureAbility.terminateSelf() + .then((data) => { + console.info('PageAbility terminateself succeeded: ' + data); + }).catch((error) => { + console.error('PageAbility terminateself failed. Cause: ' + error); + }) + }, 8000); + }, + + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/PageAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/PageAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..e6d419d27b5849adc22293b52f5abf3232e852e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/PageAbility/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 - PageAbility-B' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9e8ab66979f59c8109f65c8f2a4f21867fbf44b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e9ceb262bf44ec47c3b68f991b633e3306ae00b4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "PageAbility_desc", + "value": "description" + }, + { + "name": "PageAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/freeinstallstartabilityforresultfatest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..01e6284e03dbb6b9619971b781abca95b8af0a8c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/BUILD.gn @@ -0,0 +1,32 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("StartAbilityForResultNoTargetFaTest") { + hap_profile = "./entry/src/main/config.json" + deps = [ + ":startabilityforresultnotargetfatest_ets_assets", + ":startabilityforresultnotargetfatest_ets_resources", + ] + ets2abc = true + certificate_profile = "./signature/openharmony_sx.p7b" + hap_name = "StartAbilityForResultNoTargetFaTest" +} +ohos_js_assets("startabilityforresultnotargetfatest_ets_assets") { + source_dir = "./entry/src/main/ets/MainAbility" +} +ohos_resources("startabilityforresultnotargetfatest_ets_resources") { + sources = [ "./entry/src/main/resources" ] + hap_profile = "./entry/src/main/config.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..723dee8a530c69145e443e0876597486f36ac2ef --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/Test.json @@ -0,0 +1,34 @@ +{ + "description": "Configuration for startabilityforresultnotargetfatest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.open.harmony.startAbilityForResult", + "package-name": "com.open.harmony.startAbilityForResult", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "StartAbilityForResultNoTargetFaTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "AtomizationResultFaEntry.hap -> /data/test/AtomizationResultFaEntry.hap", + "FaResultMyApplication1.hap -> /data/test/FaResultMyApplication1.hap", + "MockService.hap -> /data/test/MockService.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/config.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..c9018fcfd254b06ce0a6c57a9ba8bca7433cb4af --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/config.json @@ -0,0 +1,116 @@ +{ + "app": { + "vendor": "example", + "bundleName": "com.open.harmony.startAbilityForResult", + "version": { + "code": 1000000, + "name": "1.0.0" + }, + "apiVersion": { + "compatible": 8, + "releaseType": "Release", + "target": 8 + } + }, + "deviceConfig": {}, + "module": { + "mainAbility": ".MainAbility", + "deviceType": [ + "phone", + "tablet" + ], + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "visible": true, + "srcPath": "MainAbility", + "name": ".MainAbility", + "srcLanguage": "ets", + "icon": "$media:icon", + "description": "$string:MainAbility_desc", + "formsEnabled": false, + "label": "$string:MainAbility_label", + "type": "page", + "launchType": "standard" + } + ], + "distro": { + "moduleType": "entry", + "installationFree": false, + "deliveryWithInstall": true, + "moduleName": "entry" + }, + "package": "com.open.harmony.startAbilityForResult", + "srcPath": "", + "name": ".entry", + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + }, + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".PageAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "reason": "need use ohos.permission.INSTALL_BUNDLE", + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.MANAGE_MISSIONS" + }, + { + "reason": "need use ohos.permission.INSTALL_BUNDLE", + "name": "ohos.permission.INSTALL_BUNDLE" + }, + { + "reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE", + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "reason": "need use ohos.permission.REMOVE_CACHE_FILES", + "name": "ohos.permission.REMOVE_CACHE_FILES" + }, + { + "reason": "need use ohos.permission.LISTEN_BUNDLE_CHANGE", + "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/app.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..e50dc2a8943d97888deef5b4b36106f52663efc1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..a422068c451a77f4a692c79937c7f49c83d1abc4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,85 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 router from '@system.router'; +import file from '@system.file'; +import {Core, ExpectExtend, InstrumentLog, ReportExtend,expect} from "deccjsunit/index"; +import testsuite from "../test/List.test"; +import featureAbility from "@ohos.ability.featureAbility"; + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + featureAbility.getWant() + .then((Want) => { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const reportExtend = new ReportExtend(file); + core.addService('report', reportExtend); + core.init(); + Want.parameters.timeout = 50000; + core.subscribeEvent('task', reportExtend); + const configService = core.getDefaultService('config'); + console.info('parameters---->' + JSON.stringify(Want.parameters)); + configService.setConfig(Want.parameters); + testsuite(); + core.execute(); + console.info('Operation successful. Data: ' + JSON.stringify(Want)); + }) + .catch((error) => { + console.error('Operation failed. Cause: ' + JSON.stringify(error)); + }) + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text(' FA- StartAbilityForResult- NoTargetBundleList TEST ') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/List.test.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..190e5b62c96eb83d2d058e66b05389a8b0c2a67d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/List.test.ets @@ -0,0 +1,21 @@ +/** + * Copyright (c) 2022 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 StartAbilityForResult from "./StartAbilityForResult.test"; + +export default function testsuite() { + StartAbilityForResult(); + + +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult.test.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb8422c23cdb7749f176fb52e7418c43abb4c85e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/StartAbilityForResult.test.ets @@ -0,0 +1,184 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 "deccjsunit/index"; +import Utils from './Utils'; +import featureAbility from "@ohos.ability.featureAbility"; +import wantConstant from '@ohos.ability.wantConstant'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +export default function StartAbilityForResult() { + var TAG = ""; + + describe('StartAbilityForResult', function () { + var delegator = AbilityDelegatorRegistry.getAbilityDelegator(); + beforeAll(async function (done) { + console.info("StartAbilityForResult before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd3 = "cp data/test/AtomizationResultFaEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/" + + "files"; + delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityForResult after each called"); + if ("FreeInstall_FA_StartAbilityForResult_2900" === TAG) { + var cmd4 = "bm uninstall -n com.ohos.hag.famanager"; + delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd5 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + delegator.executeShellCommand(cmd5, (err: any, d: any) => { + console.info("executeShellCommand5: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await Utils.sleep(500); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_2700 + * @tc.name: startAbilityForResult: NoTargetBundleList,free install successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_2700", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_2700-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_2700"; + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_2800 + * @tc.name: startAbilityForResult: NoTargetBundleList and yuanzihua already installed,startAbility successfully + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_2800", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_2800-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_2800"; + var cmd6 = "bm install -p data/test/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd6, (err: any, d: any) => { + console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let details; + var str = { + 'want': { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error)); + }) + await Utils.sleep(1000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_FA_StartAbilityForResult_2900 + * @tc.name: startAbilityForResult: The same application does not need to check targetbundlelist, + start feature hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_FA_StartAbilityForResult_2900", 0, async function (done) { + console.log("------------start FreeInstall_FA_StartAbilityForResult_2900-------------"); + TAG = "FreeInstall_FA_StartAbilityForResult_2900"; + var cmd7 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultFaEntry.hap"; + delegator.executeShellCommand(cmd7, (err: any, d: any) => { + console.info("executeShellCommand7: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + var cmd8 = "cp data/test/FaResultMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + delegator.executeShellCommand(cmd8, (err: any, d: any) => { + console.info("executeShellCommand8: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await Utils.sleep(500); + let details; + var str = { + 'want': { + "bundleName": "com.open.harmony.startAbilityForResult", + "abilityName": "com.example.myapplication1.MainAbility1", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + } + await featureAbility.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResult successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResult failed. error: ' + JSON.stringify(error)); + }) + await Utils.sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/Utils.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..59a63137a97bfe99d8ea4933c0fba9ce7bcb0765 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/MainAbility/test/Utils.ets @@ -0,0 +1,130 @@ +// @ts-nocheck +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Utils { + static rect_left; + static rect_top; + static rect_right; + static rect_bottom; + static rect_value; + + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve() + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getComponentRect(key) { + let strJson = getInspectorByKey(key); + let obj = JSON.parse(strJson); + console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj)); + let rectInfo = JSON.parse('[' + obj.$rect + ']') + console.info("[getInspectorByKey] rectInfo is: " + rectInfo); + this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0] + this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1] + this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0] + this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1] + return this.rect_value = { + "left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom + } + } + + static async swipe(downX, downY, upX, upY, steps) { + console.info('start to swipe') + this.drags(downX, downY, upX, upY, steps, false) + } + + static async drag(downX, downY, upX, upY, steps) { + console.info('start to drag') + this.drags(downX, downY, upX, upY, steps, true) + } + + static async drags(downX, downY, upX, upY, steps, drag) { + var xStep; + var yStep; + var swipeSteps; + var ret; + xStep = 0; + yStep = 0; + ret = false; + swipeSteps = steps; + if (swipeSteps == 0) { + swipeSteps = 1; + } + xStep = (upX - downX) / swipeSteps; + yStep = (upY - downY) / swipeSteps; + console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep) + var downPonit: TouchObject = { + id: 1, + x: downX, + y: downY, + type: TouchType.Down, + } + console.info('down touch started: ' + JSON.stringify(downPonit)) + sendTouchEvent(downPonit); + console.info('start to move') + if (drag) { + await this.sleep(500) + } + for (var i = 1;i <= swipeSteps; i++) { + var movePoint: TouchObject = { + id: 1, + x: downX + (xStep * i), + y: downY + (yStep * i), + type: TouchType.Move + } + console.info('move touch started: ' + JSON.stringify(movePoint)) + ret = sendTouchEvent(movePoint) + if (ret == false) { + break; + } + await this.sleep(5) + } + console.info('start to up') + if (drag) { + await this.sleep(100) + } + var upPoint: TouchObject = { + id: 1, + x: upX, + y: upY, + type: TouchType.Up, + } + console.info('up touch started: ' + JSON.stringify(upPoint)) + sendTouchEvent(upPoint) + await this.sleep(500) + } + + static getNowTime() { + return new Date().getTime(); + } + + static getDurationTime(log,startTime, endTime) { + console.info("Get Interface startTime: " + startTime); + console.info("Get Interface endTime: " + endTime); + var duration = (endTime - startTime); + console.info("Get Interface duration: " + duration); + return duration; + } +} + + + + diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..f9e8ab66979f59c8109f65c8f2a4f21867fbf44b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s package' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key] + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log('onAbilityCreateCallback'); +} + +async function addAbilityMonitorCallback(err: any) { + console.info('addAbilityMonitorCallback : ' + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info('OpenHarmonyTestRunner OnPrepare') + } + + onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility' + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext') + var context = abilityDelegator.getAppContext() + console.info('getAppContext : ' + JSON.stringify(context)) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e9ceb262bf44ec47c3b68f991b633e3306ae00b4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "PageAbility_desc", + "value": "description" + }, + { + "name": "PageAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultfatest/startabilityforresultnotargetfatest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c82b4e86496b8cd5ad551a1b75b789082e0f322e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3e0de406831ada72efc7a86a1221dfa37765ea7c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "yuanzihua" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fda01e92f0fa39b942554e7fdb6a84c2ee093a9d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationResultStageEntry") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":atomizationresultstageentry_js_assets", + ":atomizationresultstageentry_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "AtomizationResultStageEntry" +} + +ohos_app_scope("atomizationresultstageentry_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("atomizationresultstageentry_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("atomizationresultstageentry_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":atomizationresultstageentry_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ae9a6b889fefe23bb53be0b57b45e6ccf619d3e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..396606ff7396988f0849e54a294700ad86e22678 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..fb41b82036e4a81e2dfee7464b6a0a139bec45d4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + setTimeout(function () { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + globalThis.abilityContext.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "MainAbility", + }, + } + ); + globalThis.abilityContext.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + }, 1000); + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..28a7693c593a3a2ff354af01293030264925803b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/ets/pages/index.ets @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2022 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 router from '@system.router'; + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + private height: number = 25 + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('同应用不需要检查targetbundlelist名单') + .fontSize(20) + }.type(ButtonType.Capsule) + .margin({top: 20}) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage('pages/sameAppModel') + }) + + Button() { + Text('StartAbilityForResult') + .fontSize(20) + }.type(ButtonType.Capsule) + .margin({top: 20}) + .backgroundColor('#0D9FFB') + .onClick(() => { + this.terminateSelfWithResult(); + }) + } + .width('100%') + .height('100%') + } + + async terminateSelfWithResult() { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + await globalThis.abilityContext.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "MainAbility", + }, + } + ); + await globalThis.abilityContext.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + globalThis.abilityContext.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } +} + +async function routePage(page) { + let options = { + uri: page + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..2f4cd628c66961230f25795be61b8c448743d45d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.qianyiyingyong.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/element/float.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..560b68deaa3ad094fd90fb438d41ded9256573ba --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/element/float.json @@ -0,0 +1,128 @@ +{ + "float": [ + { + "name": "wh_value_1", + "value": "1" + }, + { + "name": "wh_value_5", + "value": "5" + }, + { + "name": "wh_value_10", + "value": "10" + }, + { + "name": "wh_value_15", + "value": "15" + }, + { + "name": "wh_value_20", + "value": "20" + }, + { + "name": "wh_value_25", + "value": "25" + }, + { + "name": "wh_value_30", + "value": "30" + }, + { + "name": "wh_value_40", + "value": "40" + }, + { + "name": "wh_value_50", + "value": "50" + }, + { + "name": "wh_value_60", + "value": "60" + }, + { + "name": "wh_value_65", + "value": "65" + }, + { + "name": "wh_value_70", + "value": "70" + }, + { + "name": "wh_value_80", + "value": "80" + }, + { + "name": "wh_value_100", + "value": "100" + }, + { + "name": "wh_value_130", + "value": "1300" + }, + { + "name": "wh_value_160", + "value": "160" + }, + { + "name": "wh_value_230", + "value": "230" + }, + { + "name": "wh_value_280", + "value": "280" + }, + { + "name": "wh_value_390", + "value": "390" + }, + { + "name": "wh_value_400", + "value": "400" + }, + { + "name": "font_35", + "value": "35" + }, + { + "name": "font_18", + "value": "18" + }, + { + "name": "font_20", + "value": "20" + }, + { + "name": "font_21", + "value": "21" + }, + { + "name": "font_22", + "value": "22" + }, + { + "name": "font_24", + "value": "24" + }, + { + "name": "font_28", + "value": "28" + }, + { + "name": "font_50", + "value": "50" + }, + { + "name": "control_common_font_size", + "value": "20" + }, + { + "name": "slider_text_padding_left", + "value": "5" + }, + { + "name": "volume_border_radius", + "value": "15" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..490210a3908f47722dc942d49dacc98b97669a5f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..4f0fe138cfeefd707fa478f44c9965c2aaea85d2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstageentry/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c82b4e86496b8cd5ad551a1b75b789082e0f322e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3e0de406831ada72efc7a86a1221dfa37765ea7c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "yuanzihua" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..9781edd6f1f4f32a8b07cefc48754f46f2a73479 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationResultStageHm2") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":atomizationresultstagehm2_js_assets", + ":atomizationresultstagehm2_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "AtomizationResultStageHm2" +} + +ohos_app_scope("atomizationresultstagehm2_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("atomizationresultstagehm2_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("atomizationresultstagehm2_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":atomizationresultstagehm2_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ae9a6b889fefe23bb53be0b57b45e6ccf619d3e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..396606ff7396988f0849e54a294700ad86e22678 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d022ce9f570c68679325688e05cfe14ad39a6c7 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "pages/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + setTimeout(function () { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + globalThis.abilityContext.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "hnm2MainAbility", + }, + } + ); + globalThis.abilityContext.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + }, 1000); + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2265da4fb343f2cacc3feccadfe61c19a0141dd3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/pages/index.ets @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2022 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 router from '@system.router'; +import wantConstant from '@ohos.ability.wantConstant' +import bundleManager from '@ohos.bundle'; +import Prompt from '@system.prompt'; + +const BUNDLE_NAME = 'com.example.qianyiyingyong.hmservice'; +const ABILITY_NAME1 = 'hnm2MainAbility'; + +@Entry +@Component +struct Index { + private backgroundColor = Color.Grey; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + + Button() { + Text('fAStartAbilityPromiseSameBundleName1 本设备,feature覆盖安装') + .fontSize($r('app.float.font_28')) + .width('100%') + .fontColor(Color.White) + .align(Alignment.Center) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) + } + .backgroundColor('#0D9FFB') + .height($r('app.float.wh_value_60')) + .margin({ + left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15'), + top: $r('app.float.wh_value_15') + }) + .onClick(() => { + var str = { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND + }; + this.fAStartAbilityPromise('fAStartAbilityPromiseSameBundleName1', str); + }) + + Button() { + Text('fAStartAbilityPromiseSameBundleName006 在免安装更新的时候需先设置updateModuleUpgradeFlag') + .fontSize($r('app.float.font_28')) + .width('100%') + .fontColor(Color.White) + .align(Alignment.Center) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) + } + .backgroundColor('#0D9FFB') + .margin({left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15'), + top: $r('app.float.wh_value_15') + }) + .onClick(() => { + var str = { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND + }; + this.updateModuleUpgradeFlag('fAStartAbilityPromiseSameBundleName006','feature'); + }) + + Button() { + Text('StartAbilityForResult') + .fontSize(25) + .fontColor(Color.White) + .margin({ left: $r('app.float.wh_value_30'), right: $r('app.float.wh_value_30') }) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + this.terminateSelfWithResult(); + }) + } + .width('100%') + .height('100%') + } + + async updateModuleUpgradeFlag(tag, type1) { + console.info(tag + ' startAbility fAStartAbilityPromise START' + JSON.stringify(type1)); +// await bundleManager.updateModuleUpgradeFlag("com.example.qianyiyingyong.hmservice", type1, true); + console.info(tag + ' startAbility fAStartAbilityPromise END'); + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + globalThis.abilityContext.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } + + async terminateSelfWithResult() { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + await globalThis.abilityContext.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME1, + }, + } + ); + await globalThis.abilityContext.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + } + + async fAStartAbilityPromise(tag, str) { + console.info(tag + ' startAbility fAStartAbilityPromise START' + JSON.stringify(str)); + let code; + await globalThis.abilityContext.startAbility(str) + .then((data) => { + console.info(tag + ' startAbility Operation successful. Promise Data: ' + JSON.stringify(data)) + code = data; + }).catch((error) => { + console.info(tag + ' startAbility Operation failed. Promise Cause: ' + JSON.stringify(error)); + code = error; + }) + console.info(tag + ' startAbility Operation code Promise: ' + JSON.stringify(code)); + if (code === 0) { + this.tips('成功'); + } else { + this.tips('错误码:' + code.code); + } + console.info(tag + ' startAbility fAStartAbilityPromise END'); + } + + tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..fedd7d8b45bc39605c3cd4557effb440f7f1742e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/ets/pages/second.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 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 = 'hnm2 page' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..12ecea716d57ff14c14c72866175e9521ac9d0db --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "hnm2", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:hnm2_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.hm2.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/element/float.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..560b68deaa3ad094fd90fb438d41ded9256573ba --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/element/float.json @@ -0,0 +1,128 @@ +{ + "float": [ + { + "name": "wh_value_1", + "value": "1" + }, + { + "name": "wh_value_5", + "value": "5" + }, + { + "name": "wh_value_10", + "value": "10" + }, + { + "name": "wh_value_15", + "value": "15" + }, + { + "name": "wh_value_20", + "value": "20" + }, + { + "name": "wh_value_25", + "value": "25" + }, + { + "name": "wh_value_30", + "value": "30" + }, + { + "name": "wh_value_40", + "value": "40" + }, + { + "name": "wh_value_50", + "value": "50" + }, + { + "name": "wh_value_60", + "value": "60" + }, + { + "name": "wh_value_65", + "value": "65" + }, + { + "name": "wh_value_70", + "value": "70" + }, + { + "name": "wh_value_80", + "value": "80" + }, + { + "name": "wh_value_100", + "value": "100" + }, + { + "name": "wh_value_130", + "value": "1300" + }, + { + "name": "wh_value_160", + "value": "160" + }, + { + "name": "wh_value_230", + "value": "230" + }, + { + "name": "wh_value_280", + "value": "280" + }, + { + "name": "wh_value_390", + "value": "390" + }, + { + "name": "wh_value_400", + "value": "400" + }, + { + "name": "font_35", + "value": "35" + }, + { + "name": "font_18", + "value": "18" + }, + { + "name": "font_20", + "value": "20" + }, + { + "name": "font_21", + "value": "21" + }, + { + "name": "font_22", + "value": "22" + }, + { + "name": "font_24", + "value": "24" + }, + { + "name": "font_28", + "value": "28" + }, + { + "name": "font_50", + "value": "50" + }, + { + "name": "control_common_font_size", + "value": "20" + }, + { + "name": "slider_text_padding_left", + "value": "5" + }, + { + "name": "volume_border_radius", + "value": "15" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3b3102318d47a649239586efb41fbe8abedaa392 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "hnm2_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehm2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c82b4e86496b8cd5ad551a1b75b789082e0f322e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3e0de406831ada72efc7a86a1221dfa37765ea7c --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "yuanzihua" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..53cf287b2b14230a7b9d3413670a31513f46527b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationResultStageHnm2") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":atomizationresultstagehnm2_js_assets", + ":atomizationresultstagehnm2_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "AtomizationResultStageHnm2" +} + +ohos_app_scope("atomizationresultstagehnm2_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("atomizationresultstagehnm2_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("atomizationresultstagehnm2_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":atomizationresultstagehnm2_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ae9a6b889fefe23bb53be0b57b45e6ccf619d3e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..396606ff7396988f0849e54a294700ad86e22678 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1d022ce9f570c68679325688e05cfe14ad39a6c7 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "pages/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + setTimeout(function () { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + globalThis.abilityContext.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "hnm2MainAbility", + }, + } + ); + globalThis.abilityContext.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + }, 1000); + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..2265da4fb343f2cacc3feccadfe61c19a0141dd3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/pages/index.ets @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2022 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 router from '@system.router'; +import wantConstant from '@ohos.ability.wantConstant' +import bundleManager from '@ohos.bundle'; +import Prompt from '@system.prompt'; + +const BUNDLE_NAME = 'com.example.qianyiyingyong.hmservice'; +const ABILITY_NAME1 = 'hnm2MainAbility'; + +@Entry +@Component +struct Index { + private backgroundColor = Color.Grey; + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + + Button() { + Text('fAStartAbilityPromiseSameBundleName1 本设备,feature覆盖安装') + .fontSize($r('app.float.font_28')) + .width('100%') + .fontColor(Color.White) + .align(Alignment.Center) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) + } + .backgroundColor('#0D9FFB') + .height($r('app.float.wh_value_60')) + .margin({ + left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15'), + top: $r('app.float.wh_value_15') + }) + .onClick(() => { + var str = { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND + }; + this.fAStartAbilityPromise('fAStartAbilityPromiseSameBundleName1', str); + }) + + Button() { + Text('fAStartAbilityPromiseSameBundleName006 在免安装更新的时候需先设置updateModuleUpgradeFlag') + .fontSize($r('app.float.font_28')) + .width('100%') + .fontColor(Color.White) + .align(Alignment.Center) + .margin({ left: $r('app.float.wh_value_15'), right: $r('app.float.wh_value_15') }) + } + .backgroundColor('#0D9FFB') + .margin({left: $r('app.float.wh_value_15'), + right: $r('app.float.wh_value_15'), + top: $r('app.float.wh_value_15') + }) + .onClick(() => { + var str = { + 'bundleName': BUNDLE_NAME, + 'abilityName': ABILITY_NAME1, + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND + }; + this.updateModuleUpgradeFlag('fAStartAbilityPromiseSameBundleName006','feature'); + }) + + Button() { + Text('StartAbilityForResult') + .fontSize(25) + .fontColor(Color.White) + .margin({ left: $r('app.float.wh_value_30'), right: $r('app.float.wh_value_30') }) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + this.terminateSelfWithResult(); + }) + } + .width('100%') + .height('100%') + } + + async updateModuleUpgradeFlag(tag, type1) { + console.info(tag + ' startAbility fAStartAbilityPromise START' + JSON.stringify(type1)); +// await bundleManager.updateModuleUpgradeFlag("com.example.qianyiyingyong.hmservice", type1, true); + console.info(tag + ' startAbility fAStartAbilityPromise END'); + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + globalThis.abilityContext.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } + + async terminateSelfWithResult() { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + await globalThis.abilityContext.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: BUNDLE_NAME, + abilityName: ABILITY_NAME1, + }, + } + ); + await globalThis.abilityContext.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + } + + async fAStartAbilityPromise(tag, str) { + console.info(tag + ' startAbility fAStartAbilityPromise START' + JSON.stringify(str)); + let code; + await globalThis.abilityContext.startAbility(str) + .then((data) => { + console.info(tag + ' startAbility Operation successful. Promise Data: ' + JSON.stringify(data)) + code = data; + }).catch((error) => { + console.info(tag + ' startAbility Operation failed. Promise Cause: ' + JSON.stringify(error)); + code = error; + }) + console.info(tag + ' startAbility Operation code Promise: ' + JSON.stringify(code)); + if (code === 0) { + this.tips('成功'); + } else { + this.tips('错误码:' + code.code); + } + console.info(tag + ' startAbility fAStartAbilityPromise END'); + } + + tips(msg) { + Prompt.showToast({ + message: msg, + duration: 2000, + bottom: '150px' + }); + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..fedd7d8b45bc39605c3cd4557effb440f7f1742e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/ets/pages/second.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2022 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 = 'hnm2 page' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..14ecbbe576f2cf026f8c4a7b7737dee204ab13b3 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "hnm2", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:hnm2_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.qianyiyingyong.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/element/float.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..560b68deaa3ad094fd90fb438d41ded9256573ba --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/element/float.json @@ -0,0 +1,128 @@ +{ + "float": [ + { + "name": "wh_value_1", + "value": "1" + }, + { + "name": "wh_value_5", + "value": "5" + }, + { + "name": "wh_value_10", + "value": "10" + }, + { + "name": "wh_value_15", + "value": "15" + }, + { + "name": "wh_value_20", + "value": "20" + }, + { + "name": "wh_value_25", + "value": "25" + }, + { + "name": "wh_value_30", + "value": "30" + }, + { + "name": "wh_value_40", + "value": "40" + }, + { + "name": "wh_value_50", + "value": "50" + }, + { + "name": "wh_value_60", + "value": "60" + }, + { + "name": "wh_value_65", + "value": "65" + }, + { + "name": "wh_value_70", + "value": "70" + }, + { + "name": "wh_value_80", + "value": "80" + }, + { + "name": "wh_value_100", + "value": "100" + }, + { + "name": "wh_value_130", + "value": "1300" + }, + { + "name": "wh_value_160", + "value": "160" + }, + { + "name": "wh_value_230", + "value": "230" + }, + { + "name": "wh_value_280", + "value": "280" + }, + { + "name": "wh_value_390", + "value": "390" + }, + { + "name": "wh_value_400", + "value": "400" + }, + { + "name": "font_35", + "value": "35" + }, + { + "name": "font_18", + "value": "18" + }, + { + "name": "font_20", + "value": "20" + }, + { + "name": "font_21", + "value": "21" + }, + { + "name": "font_22", + "value": "22" + }, + { + "name": "font_24", + "value": "24" + }, + { + "name": "font_28", + "value": "28" + }, + { + "name": "font_50", + "value": "50" + }, + { + "name": "control_common_font_size", + "value": "20" + }, + { + "name": "slider_text_padding_left", + "value": "5" + }, + { + "name": "volume_border_radius", + "value": "15" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3b3102318d47a649239586efb41fbe8abedaa392 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "hnm2_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/atomizationresultstagehnm2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..1d8c9524ed9090c76bec92a8516e4a0235e1a0b2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.startAbilityForResult.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "targetBundleList": [ + "com.example.qianyiyingyong.hmservice" + ] + } + } + \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..247ee4447e61d4d023eb58dff6b5898fd94d4669 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "FreeInstall3_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..4412327012625c57bd0e6923af73125a938b20d4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FreeInstallStartAbilityForResultStageTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":freeinstallstartabilityforresultstagetest_js_assets", + ":freeinstallstartabilityforresultstagetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FreeInstallStartAbilityForResultStageTest" +} + +ohos_app_scope("freeinstallstartabilityforresultstagetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("freeinstallstartabilityforresultstagetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("freeinstallstartabilityforresultstagetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":freeinstallstartabilityforresultstagetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..e2cfccad122c9463966476f1d1af1202a9c805cf --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/Test.json @@ -0,0 +1,36 @@ +{ + "description": "Configuration for freeinstallstartabilityforresultstagetest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.startAbilityForResult.hmservice", + "module-name": "entry", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "FreeInstallStartAbilityForResultStageTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "atomizationresultstageentry.hap -> /data/test/AtomizationResultStageEntry.hap", + "atomizationresultstagehm2.hap -> /data/test/AtomizationResultStageHm2.hap", + "atomizationresultstagehnm2.hap -> /data/test/AtomizationResultStageHnm2.hap", + "stageresultmyapplication1.hap -> /data/test/StageResultMyApplication1.hap", + "MockService.hap -> /data/test/MockService.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..396606ff7396988f0849e54a294700ad86e22678 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2879c19bb8224886f189e4cab1b57a99a1c97e9f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability'; + + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec20fc0823ea020a5e20468f96d136147dd3a2b8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + globalThis.delegator = abilityDelegator; + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb2b61d0f92f4c740f185c9458ab844f9bbe1842 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,74 @@ +// @ts-nocheck +/* + * Copyright (c) 2022 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 router from '@system.router'; +import file from '@system.file'; +import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" +import List from '../test/ListTest' + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + core.addService('report', reportExtend) + core.init() + globalThis.abilityWant.parameters.timeout = 16000; + core.subscribeEvent('task', reportExtend) + const configService = core.getDefaultService('config') + configService.setConfig(globalThis.abilityWant.parameters); + List(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/ListTest.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/ListTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e135465f062b3338559a9ba46054ffa997078573 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/ListTest.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 StartAbilityForResult from './StartAbilityForResult' + +export default function List(context) { + + StartAbilityForResult(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/StartAbilityForResult.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/StartAbilityForResult.ets new file mode 100644 index 0000000000000000000000000000000000000000..07f3190e242b20ba3b7497e91a3e9e3f66c4b6d8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/StartAbilityForResult.ets @@ -0,0 +1,529 @@ +// @ts-nocheck +/* + * Copyright (c) 2022 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 "deccjsunit/index" +import ability from '@ohos.application.Ability' +import rpc from '@ohos.rpc'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; +import abilityManager from '@ohos.application.abilityManager'; + + +export default function StartAbilityForResult(abilityContext) { + var TAG = ""; + var DeviceId = ""; + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + describe('StartAbilityForResult', function () { + beforeAll(async function (done) { + console.info("StartAbilityForResult before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : "+cmd) + globalThis.delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + globalThis.delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd3 ="cp data/test/AtomizationResultStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityForResult after each called"); + if ("FreeInstall_Stage_StartAbilityForResult_0100" === TAG || + "FreeInstall_Stage_StartAbilityForResult_0500" === TAG || + "FreeInstall_Stage_StartAbilityForResult_2800" === TAG) { + var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + globalThis.delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + } + if ("FreeInstall_Stage_StartAbilityForResult_0700" === TAG) { + var cmd5 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultStageHm2.hap"; + globalThis.delegator.executeShellCommand(cmd5, (err: any, d: any) => { + console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd6 = "cp data/test/AtomizationResultStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + globalThis.delegator.executeShellCommand(cmd6, (err: any, d: any) => { + console.info("executeShellCommand6 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + } + if ("FreeInstall_Stage_StartAbilityForResult_2600" === TAG) { + var cmd14 = "bm uninstall -n com.ohos.hag.famanager"; + globalThis.delegator.executeShellCommand(cmd14, (err: any, d: any) => { + console.info("executeShellCommand14 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await sleep(500); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_0100 + * @tc.name: startAbilityForResult: Input empty deviceId,free install and start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_0100", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_0100-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_0100"; + let details; + var str = { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_0400 + * @tc.name: startAbilityForResult: No deviceId,free install and start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_0400", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_0400-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_0400"; + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + var options = { + "windowMode": 0, "displayId": 2 + } + await globalThis.abilityContext.startAbilityForResult(str, options) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_0500 + * @tc.name: startAbilityForResult: app already installed, start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_0500", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_0500-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_0500"; + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_0600 + * @tc.name: startAbilityForResult: Input local deviceId,free install and start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_0600", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_0600-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_0600"; + let details1; + let details2; + await abilityManager.getTopAbility().then((data) => { + details1 = data; + console.info(' getTopAbility succeeded data: ' + JSON.stringify(data)); + }).catch((error) => { + console.error(' getTopAbility error: ' + JSON.stringify(error)); + }); + console.log(" checkAbilityInfo deviceId : " + details1.ability.deviceId); + DeviceId = details1.ability.deviceId; + await sleep(500); + var str = { + "deviceId": DeviceId, + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details2 = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details2.resultCode); + expect(details2.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_0700 + * @tc.name: startAbilityForResult: Free install and start feature hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_0700", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_0700-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_0700"; + var cmd7 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd7, (err: any, d: any) => { + console.info("executeShellCommand7: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd8 = "cp data/test/AtomizationResultStageHm2.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd8, (err: any, d: any) => { + console.info("executeShellCommand8: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hnm2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_0800 + * @tc.name: startAbilityForResult: Call by AsyncCallback,free install and start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_0800", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_0800-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_0800"; + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + var options = { + "windowMode": 0, "displayId": 2 + } + await globalThis.abilityContext.startAbilityForResult(str, options, (err, data) => { + console.log(TAG + ": StartAbilityForResultCallBack success, err: " + JSON.stringify(err) + + ",data: " + JSON.stringify(data)); + details = data; + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_1200 + * @tc.name: startAbilityForResult: Yuanzihua already installed,input wrong flags,start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_1200", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_1200-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_1200"; + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': '11' + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_1400 + * @tc.name: startAbilityForResult: Yuanzihua already installed,input wrong flags,add options,start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_1400", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_1400-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_1400"; + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': '11' + } + var options = { + "windowMode": 0, "displayId": 2 + } + await globalThis.abilityContext.startAbilityForResult(str, options) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_1600 + * @tc.name: startAbilityForResult: Yuanzihua already installed,input empty flags,start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_1600", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_1600-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_1600"; + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': '' + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_1800 + * @tc.name: startAbilityForResult: Yuanzihua already installed,input empty flags,add options,start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_1800", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_1800-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_1800"; + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + 'flags': '' + } + var options = { + "windowMode": 0, "displayId": 2 + } + await globalThis.abilityContext.startAbilityForResult(str, options) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_2700 + * @tc.name: startAbilityForResult: Input different moduleName(feature hap),install feature hap. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_2700", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_2700-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_2700"; + var cmd9 = "bm install -p data/test/AtomizationResultStageHnm2.hap"; + globalThis.delegator.executeShellCommand(cmd9, (err: any, d: any) => { + console.info("executeShellCommand9: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "hnm2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_2800 + * @tc.name: startAbilityForResult: Input parameters extended information. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_2800", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_2800-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_2800"; + var cmd10 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + globalThis.delegator.executeShellCommand(cmd10, (err: any, d: any) => { + console.info("executeShellCommand10 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd11 = "cp data/test/AtomizationResultStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd11, (err: any, d: any) => { + console.info("executeShellCommand11 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + 'deviceId': '', + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + 'parameters': {"name": "1111", "Ext2": "ExtValue2","site":"很开心看到你!"} + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_2600 + * @tc.name: startAbilityForResult: Same application,start feature hap(not added in "targetBundleList") + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_2600", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_2600-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_2600"; + var cmd12 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationResultStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd12, (err: any, d: any) => { + console.info("executeShellCommand12 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd13 = "cp data/test/StageResultMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + globalThis.delegator.executeShellCommand(cmd13, (err: any, d: any) => { + console.info("executeShellCommand13 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + "deviceId": "", + "bundleName": "com.example.startAbilityForResult.hmservice", + "abilityName": "MainAbility1", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/Utils.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..78a775bc36e3828f6bb4292a2effa58fd940d9f1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve(reject) + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getNowTime() { + return new Date().getTime(); + } + + /** + * 接口调用时间 + * @param startTime 接口调用开始时间 + * @param endTime 接口调用结束时间 + */ + static getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; + } +} + + + + diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..f1ba526b0e06b898cfd8cdc6e67ed5d4bd584985 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/module.json @@ -0,0 +1,51 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.startAbilityForResult.hmservice.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..490210a3908f47722dc942d49dacc98b97669a5f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/freeinstallstartabilityforresultstagetest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..1d8c9524ed9090c76bec92a8516e4a0235e1a0b2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.startAbilityForResult.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "targetBundleList": [ + "com.example.qianyiyingyong.hmservice" + ] + } + } + \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..247ee4447e61d4d023eb58dff6b5898fd94d4669 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "FreeInstall3_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b0e9807bb1626cfbf42a05ba76dfcbd04c9b3039 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("StageResultMyApplication1") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":stageresultmyapplication1_js_assets", + ":stageresultmyapplication1_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "StageResultMyApplication1" +} + +ohos_app_scope("stageresultmyapplication1_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("stageresultmyapplication1_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("stageresultmyapplication1_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":stageresultmyapplication1_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ae9a6b889fefe23bb53be0b57b45e6ccf619d3e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/MainAbility1/MainAbility1.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/MainAbility1/MainAbility1.ts new file mode 100644 index 0000000000000000000000000000000000000000..af7509fe368a0f12f5f634bd87f37cdff85dd3f0 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/MainAbility1/MainAbility1.ts @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility1 extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + setTimeout(function () { + console.info('fAStartAbilityForResultPromise terminateSelfWithResult START'); + globalThis.abilityContext.terminateSelfWithResult( + { + resultCode: 1, + want: + { + bundleName: "com.example.qianyiyingyong.hmservice", + abilityName: "hnm2MainAbility", + }, + } + ); + globalThis.abilityContext.terminateSelf(); + console.info('fAStartAbilityForResultPromise terminateSelfWithResult END'); + }, 1000); + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..6e46a1b4661ec2e9ad05896e9922179720c75b94 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 - myapplication1' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..418fe1a5343885817705a3967670e4d56b45e542 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "myapplication1", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication1_desc", + "mainElement": "MainAbility1", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility1", + "srcEntrance": "./ets/MainAbility1/MainAbility1.ts", + "description": "$string:MainAbility1_desc", + "icon": "$media:icon", + "label": "$string:MainAbility1_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..0ab9f9b1dcb2df0331476e1ae3619426cf2b3b47 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "myapplication1_desc", + "value": "description" + }, + { + "name": "MainAbility1_desc", + "value": "description" + }, + { + "name": "MainAbility1_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/stageresultmyapplication1/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..e151e4ae36e43f8e2537879ede3f2a811ea4e5fd --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/app.json @@ -0,0 +1,17 @@ +{ + "app": { + "bundleName": "com.example.startAbilityForResult.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9 + } + } + \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..247ee4447e61d4d023eb58dff6b5898fd94d4669 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "FreeInstall3_XTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b29c1ddbd46a22b3beaaaad1f77643b413289966 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("StartAbilityForResultNoTargetBundleListStageTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":startabilityforresultnotargetbundleliststagetest_js_assets", + ":startabilityforresultnotargetbundleliststagetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "StartAbilityForResultNoTargetBundleListStageTest" +} + +ohos_app_scope("startabilityforresultnotargetbundleliststagetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("startabilityforresultnotargetbundleliststagetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("startabilityforresultnotargetbundleliststagetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":startabilityforresultnotargetbundleliststagetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/Test.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..0d78cfc0bf0f816073fa6b63e3e4df389f8f4989 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/Test.json @@ -0,0 +1,33 @@ +{ + "description": "Configuration for startabilityforresultnotargetbundleliststagetest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.example.startAbilityForResult.hmservice", + "module-name": "entry", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "StartAbilityForResultNoTargetBundleListStageTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "atomizationresultstageentry.hap -> /data/test/AtomizationResultStageEntry.hap", + "MockService.hap -> /data/test/MockService.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..396606ff7396988f0849e54a294700ad86e22678 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..2879c19bb8224886f189e4cab1b57a99a1c97e9f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability'; + + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + globalThis.abilityContext = this.context; + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..ec20fc0823ea020a5e20468f96d136147dd3a2b8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + globalThis.delegator = abilityDelegator; + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..fb2b61d0f92f4c740f185c9458ab844f9bbe1842 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,74 @@ +// @ts-nocheck +/* + * Copyright (c) 2022 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 router from '@system.router'; +import file from '@system.file'; +import { Core, ExpectExtend, InstrumentLog, ReportExtend } from "deccjsunit/index" +import List from '../test/ListTest' + +async function routePage() { + let options = { + uri: 'pages/second' + } + try { + await router.push(options) + } catch (err) { + console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`) + } +} + +@Entry +@Component +struct Index { + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + core.addService('report', reportExtend) + core.init() + globalThis.abilityWant.parameters.timeout = 16000; + core.subscribeEvent('task', reportExtend) + const configService = core.getDefaultService('config') + configService.setConfig(globalThis.abilityWant.parameters); + List(globalThis.abilityContext) + core.execute() + } + + build() { + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Text('Hello World') + .fontSize(50) + .fontWeight(FontWeight.Bold) + Button() { + Text('next page') + .fontSize(25) + .fontWeight(FontWeight.Bold) + }.type(ButtonType.Capsule) + .margin({ + top: 20 + }) + .backgroundColor('#0D9FFB') + .onClick(() => { + routePage() + }) + } + .width('100%') + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/ListTest.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/ListTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..e135465f062b3338559a9ba46054ffa997078573 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/ListTest.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 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 StartAbilityForResult from './StartAbilityForResult' + +export default function List(context) { + + StartAbilityForResult(context) + +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/StartAbilityForResult.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/StartAbilityForResult.ets new file mode 100644 index 0000000000000000000000000000000000000000..45e2430452bdf5a5b6c73f23c4e07a69d67a543f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/StartAbilityForResult.ets @@ -0,0 +1,135 @@ +// @ts-nocheck +/* + * Copyright (c) 2022 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 "deccjsunit/index" +import ability from '@ohos.application.Ability' +import rpc from '@ohos.rpc'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; + + +export default function StartAbilityForResult(abilityContext) { + var TAG = ""; + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + describe('StartAbilityForResult', function () { + beforeAll(async function (done) { + console.info("StartAbilityForResult before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : "+cmd) + globalThis.delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd1 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + globalThis.delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd2 = "mkdir /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd3 ="cp data/test/AtomizationResultStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityForResult after each called"); + if ("FreeInstall_Stage_StartAbilityForResult_2500") { + var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + globalThis.delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + } + var cmd5 = "bm uninstall -n com.ohos.hag.famanager"; + globalThis.delegator.executeShellCommand(cmd5, (err: any, d: any) => { + console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_2400 + * @tc.name: startAbilityForResult: don't add targetBundleList,free install and start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_2400", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_2400-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_2400"; + let details; + var str = { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + + /* + * @tc.number: FreeInstall_Stage_StartAbilityForResult_2500 + * @tc.name: startAbilityForResult: don't add targetBundleList, app already installed, start hap successfully. + * @tc.desc: Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_StartAbilityForResult_2500", 0, async function (done) { + console.log("------------start FreeInstall_Stage_StartAbilityForResult_2500-------------"); + TAG = "FreeInstall_Stage_StartAbilityForResult_2500"; + var cmd6 = "bm install -p data/test/AtomizationResultStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd6, (err: any, d: any) => { + console.info("executeShellCommand6: err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + let details; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + await globalThis.abilityContext.startAbilityForResult(str) + .then((data) => { + details = data; + console.info(TAG + ' StartAbilityForResultPromise successful. Data: ' + JSON.stringify(data)) + }).catch((error) => { + console.info(TAG + ' StartAbilityForResultPromise failed. Cause: ' + JSON.stringify(error)); + }) + await sleep(2000); + console.log(TAG + " resultCode: " + details.resultCode); + expect(details.resultCode).assertEqual(1); + done(); + }); + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/Utils.ets b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..78a775bc36e3828f6bb4292a2effa58fd940d9f1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export default class Utils { + static sleep(time) { + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve(reject) + }, time) + }).then(() => { + console.info(`sleep ${time} over...`) + }) + } + + static getNowTime() { + return new Date().getTime(); + } + + /** + * 接口调用时间 + * @param startTime 接口调用开始时间 + * @param endTime 接口调用结束时间 + */ + static getDurationTime(msg, startTime, endTime) { + console.info(msg + 'Get Interface startTime: ' + startTime); + console.info(msg + 'Get Interface endTime: ' + endTime); + var duration = (endTime - startTime) + console.info(msg + 'Get Interface Duration: ' + duration); + return duration; + } +} + + + + diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..f1ba526b0e06b898cfd8cdc6e67ed5d4bd584985 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/module.json @@ -0,0 +1,51 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.startAbilityForResult.hmservice.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..490210a3908f47722dc942d49dacc98b97669a5f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilityforresultstagetest/startabilityforresultnotargetbundleliststagetest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c82b4e86496b8cd5ad551a1b75b789082e0f322e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..97a61941f25e7ea0c92bfb154353783ff6a9cb50 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AtomizationXTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..71aa5b6089daba0195da757a9f747dcc60f430ac --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationStageEntry") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":atomizationstageentry_js_assets", + ":atomizationstageentry_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "AtomizationStageEntry" +} + +ohos_app_scope("atomizationstageentry_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("atomizationstageentry_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("atomizationstageentry_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":atomizationstageentry_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/Test.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ae9a6b889fefe23bb53be0b57b45e6ccf619d3e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..a40c991d3b5480e8485abd1ca0a790154bf4c83b --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2022 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 FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData'; + +export default class ServiceAbility extends FormExtension { + onCreate(want) { + console.info('qianyiyingyong ServiceAbility onCreate'); + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onRequest(want, startId) { + console.info('qianyiyingyong ServiceAbility onRequest'); + } + + onDestroy(formId) { + console.info('qianyiyingyong ServiceAbility onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..d2eddd72214a6dbef1a13f11f7d28893758a08ef --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/ets/pages/index.ets @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2022 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 = 'Atomizationxts entry' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } + + async aboutToAppear() { + var permissions = ["ohos.permission.DISTRIBUTED_DATASYNC"]; + globalThis.abilityContext.getContext().requestPermissionsFromUser(permissions, 0, (data) => { + console.info("start requestPermissionsFromUser!!!!") + }) + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.css b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..b52e9bfa91f56e9c07e00384da135250752a03cc --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.css @@ -0,0 +1,19 @@ +#wrapper { + flex-direction: column; +} + +#div1 { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + background-color: white; +} + +#text1 { + height: 45px; + width: 150px; + font-size: 16px; + text-align: center; +} + diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.hml b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..b01936fb18990555228d425ea5860c785862aa50 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.hml @@ -0,0 +1,7 @@ +
+
+
+ {{title}} +
+
+
\ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..1c9e2ce993cf9193502ea0a014beb511aac12a73 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/js/ServiceAbility/pages/index/index.json @@ -0,0 +1,6 @@ +{ + "actions": {}, + "data": { + "title": "Hello World" + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..8d4674b1563b9b3b0df355d5ba11c3458b5cb6a2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/module.json @@ -0,0 +1,66 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.qianyiyingyong.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ], + "extensionAbilities": [ + { + "name": "com.example.qianyiyingyong.ServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] + } + ] + } + } \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..98795c555eab1a9364980289fa2c32085fd546da --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/element/string.json @@ -0,0 +1,24 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/profile/form_config.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..4a4ad2f4f1f2648d527938b29cd404570ca5f135 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,42 @@ +{ + "forms": [ + { + "isDefault": true, + "src": "./js/widget/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "widget", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "isDefault": true, + "src": "./js/ServiceAbility/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "ServiceAbility", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstageentry/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c82b4e86496b8cd5ad551a1b75b789082e0f322e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..97a61941f25e7ea0c92bfb154353783ff6a9cb50 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AtomizationXTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..b86324ade88809131f7c281c2436681fe1a0d4b4 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationStageHm2") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":atomizationstagehm2_js_assets", + ":atomizationstagehm2_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "AtomizationStageHm2" +} + +ohos_app_scope("atomizationstagehm2_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("atomizationstagehm2_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("atomizationstagehm2_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":atomizationstagehm2_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/Test.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ae9a6b889fefe23bb53be0b57b45e6ccf619d3e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42cd7b491b4c0335c372dd534174664eecbeed80 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 = 'Atomizationxts hm2' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..752f06755763e5fcbc77016cb5bf2222165e8b6a --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/module.json @@ -0,0 +1,51 @@ +{ + "module": { + "name": "hnm2", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:hnm2_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.hm2.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ] + } + } \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3b3102318d47a649239586efb41fbe8abedaa392 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "hnm2_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm2/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..c82b4e86496b8cd5ad551a1b75b789082e0f322e --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.example.qianyiyingyong.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..97a61941f25e7ea0c92bfb154353783ff6a9cb50 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "AtomizationXTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..2f79c40d30ee796a33cab16fa56a7a39e59245e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("AtomizationStageHm4") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":atomizationstagehm4_js_assets", + ":atomizationstagehm4_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "AtomizationStageHm4" +} + +ohos_app_scope("atomizationstagehm4_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("atomizationstagehm4_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("atomizationstagehm4_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":atomizationstagehm4_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/Test.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ae9a6b889fefe23bb53be0b57b45e6ccf619d3e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..17fd45002444a80f9c334d1cfbd2942f3f810bab --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 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 = 'Atomizationxts hm4' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..02755db069282541460533e8f38a8b58fb0eae78 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "hm4", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:hm4_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.example.hm2.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..b1b20d0499a66434835da023d968dfab9c158f0d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "hm4_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/atomizationstagehm4/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..0aa998790e68fe7bfea85a9293635bd74dfdcd12 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/app.json @@ -0,0 +1,19 @@ +{ + "app": { + "bundleName": "com.open.harmony.packagemag", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "targetBundleList": [ + "com.example.qianyiyingyong.hmservice" + ] + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e2a1efdc12c2e8ae86a7fedd7bff2cf1b3a57503 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "StartAbilityXTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0d2ef9be2ff9b7185f6f9668aab1d1a8fa7e1ecc --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("FreeInstallStartAbilityStageTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":freeinstallstartabilitystagetest_js_assets", + ":freeinstallstartabilitystagetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "FreeInstallStartAbilityStageTest" +} + +ohos_app_scope("freeinstallstartabilitystagetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("freeinstallstartabilitystagetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("freeinstallstartabilitystagetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":freeinstallstartabilitystagetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/Test.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..12e0d2e5a47feebafbfbb88eb13ac173a5ae8dcc --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/Test.json @@ -0,0 +1,36 @@ +{ + "description": "Configuration for freeinstallstartabilitystagetest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.open.harmony.packagemag", + "module-name": "entry", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "FreeInstallStartAbilityStageTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "AtomizationStageEntry.hap -> /data/test/AtomizationStageEntry.hap", + "AtomizationStageHm2.hap -> /data/test/AtomizationStageHm2.hap", + "AtomizationStageHm4.hap -> /data/test/AtomizationStageHm4.hap", + "MockService.hap -> /data/test/MockService.hap", + "MockServiceTimeout.hap -> /data/test/MockServiceTimeout.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/FormAbility/FormAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/FormAbility/FormAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..f8c8f1dd9780f433952af29d2050109185fa2869 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/FormAbility/FormAbility.ts @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2022 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 FormExtension from '@ohos.application.FormExtension'; +import formBindingData from '@ohos.application.formBindingData'; +import formInfo from '@ohos.application.formInfo'; + +export default class FormAbility extends FormExtension { + onCreate(want) { + // Called to return a FormBindingData object. + let formData = {}; + return formBindingData.createFormBindingData(formData); + } + + onCastToNormal(formId) { + // Called when the form provider is notified that a temporary form is successfully + // converted to a normal form. + } + + onUpdate(formId) { + // Called to notify the form provider to update a specified form. + } + + onVisibilityChange(newStatus) { + // Called when the form provider receives form events from the system. + } + + onEvent(formId, message) { + // Called when a specified message event defined by the form provider is triggered. + } + + onDestroy(formId) { + // Called to notify the form provider that a specified form has been destroyed. + } + + onAcquireFormState(want) { + // Called to return a {@link FormState} object. + return formInfo.FormState.READY; + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9dca45fbb5d2120f45d00a5c542d6ca4139a5e12 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index", null) + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/MainAbility1/MainAbility1.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/MainAbility1/MainAbility1.ts new file mode 100644 index 0000000000000000000000000000000000000000..a7b04f832a011809d9ef8a5f5d67c10d5951a3b8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/MainAbility1/MainAbility1.ts @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility1 extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility1 onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility1 onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility1 onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/second", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility1 onWindowStageDestroy") + + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility1 onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility1 onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..593dc9add0f7bdd6b7b988a96dbe685ebc730c31 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/ServiceAbility/ServiceAbility.ts @@ -0,0 +1,63 @@ +/** + * Copyright (c) 2022 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 ServiceExtensionAbility from '@ohos.application.ServiceExtensionAbility'; +import wantConstant from '@ohos.ability.wantConstant'; +import commonEvent from '@ohos.commonEvent'; + +var publishOptions = { + parameters: { + "assertData": "onSuccess" + } +}; + +function PublishCallBack(err) { + if (err.code) { + console.error("ConnectAbilityTest_Ext service publish failed " + JSON.stringify(err)); + } else { + console.info("ConnectAbilityTest_Ext service publish success!!!"); + } +} + +export default class ServiceAbility extends ServiceExtensionAbility { + onCreate() { + console.info('ServiceAbility2 onCreate'); + } + + onRequest(want, startId) { + console.info('ServiceAbility2 onRequest, want: ' + want.abilityName); + console.info('ServiceAbility2 onRequest, startId: ' + startId); + console.info('ServiceAbility2 onRequest'); + let str = { + 'deviceId': '', + 'bundleName': 'com.example.qianyiyingyong.hmservice', + 'abilityName': 'com.example.qianyiyingyong.ServiceAbility', + 'moduleName': 'entry', + 'flags': wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + console.info('ServiceAbility2 onRequest START, str is : ' + JSON.stringify(str)); + + this.context.startAbility(str).then((data) => { + console.info("ServiceAbility2 onRequest data: " + JSON.stringify(data)) + commonEvent.publish("service_event",publishOptions,PublishCallBack); + }).catch((error) => { + console.info("ServiceAbility2 onRequest error: " + JSON.stringify(error)) + }) + } + + onDestroy() { + console.info('ServiceAbility2 onDestroy'); + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c446f687cce0ed2e023e32461014af624e1ab01 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + globalThis.delegator = abilityDelegator; + + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..51801c99985b09f246a217507ed2ad6633abf253 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,56 @@ +// @ts-nocheck +/** + * Copyright (c) 2022 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 {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import file from '@system.file'; +import List from '../test/ListTest' + +@Entry +@Component +struct Index { + @State message: string = 'StartAbilityTest' + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + globalThis.abilityWant.parameters.timeout = 50000; + core.subscribeEvent('task', reportExtend) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + List(globalThis.abilityContext) + core.execute() + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/pages/second.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/pages/second.ets new file mode 100644 index 0000000000000000000000000000000000000000..d5b979d2f24cf2ec2dcb0739a861721530e0d4c1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/pages/second.ets @@ -0,0 +1,33 @@ +// @ts-nocheck +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Second { + @State message: string = 'StartAbilityTest MainAbility2' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/test/ListTest.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/test/ListTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdbb0f8cc4e70ab6e05607cc707be08528a01209 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/test/ListTest.ets @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2022 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 startAbilityTest from './StartAbilityTest' + +export default function testsuite(context) { + startAbilityTest(context) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/test/StartAbilityTest.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/test/StartAbilityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..711e077392865265941b465f9ce1a7858372b59f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/ets/test/StartAbilityTest.ets @@ -0,0 +1,1240 @@ +// @ts-nocheck + + +/** + * Copyright (c) 2022 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 "deccjsunit/index" +import ability from '@ohos.application.Ability' +import rpc from '@ohos.rpc'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; +import abilityManager from '@ohos.application.abilityManager'; +import commonEvent from '@ohos.commonEvent'; + + +export default function startAbilityTest(abilityContext) { + + describe('startAbilityTest', function () { + + console.info("-------------Stage model--> startAbilityXTS Test start----------------") + + var TAG = ""; + + globalThis.delegator.getCurrentTopAbility((err : any, data : any) => { + console.info("getCurrentTopAbility err: " + JSON.stringify(err) + ", data: " + JSON.stringify(data)); + globalThis.ability = data; + }); + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + var subscriber; + var result; + var subscribeInfo = { + events: ["service_event"] + }; + + function SubscribeCallBack(err, data) { + if (err.code) { + console.error("Testevent subscribe failed " + JSON.stringify(err)); + } else { + console.info("Testevent subscribe " + JSON.stringify(data)); + for (var key1 in data.parameters) { + console.info("Testevent data.parameters[key] is :" + data.parameters[key1]) + if (data.parameters[key1] === "onSuccess") { + result = "onSuccess" + } + } + } + } + + function CreateSubscriberCallBack(err, commonEventSubscriber) { + if (err.code) { + console.error("Testevent createSubscriber failed " + JSON.stringify(err)); + } else { + console.info("Testevent createSubscriber"); + subscriber = commonEventSubscriber; + commonEvent.subscribe(subscriber, SubscribeCallBack); + } + } + + + beforeAll(async function (done) { + console.info("StartAbilityTest before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : "+cmd) + globalThis.delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + globalThis.delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d));}) + await sleep(500); + var cmd3 ="cp data/test/AtomizationStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err)," data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityTest after each called"); + if ("FreeInstall_Stage_Local_StartAbility_0200" === TAG || + "FreeInstall_Stage_Local_StartAbility_0500" === TAG || + "FreeInstall_Stage_Local_StartAbility_0700" === TAG || + "FreeInstall_Stage_Local_StartAbility_0800" === TAG || + "FreeInstall_Stage_Local_StartAbility_1000" === TAG || + "FreeInstall_Stage_Local_StartAbility_1200" === TAG || + "FreeInstall_Stage_Local_StartAbility_1400" === TAG || + "FreeInstall_Stage_Local_StartAbility_1600" === TAG || + "FreeInstall_Stage_Local_StartAbility_1800" === TAG || + "FreeInstall_Stage_Local_StartAbility_2200" === TAG || + "FreeInstall_Stage_Local_StartAbility_2400" === TAG || + "FreeInstall_Stage_Local_StartAbility_3000" === TAG || + "FreeInstall_Stage_Local_StartAbility_3400" === TAG || + "FreeInstall_Stage_Local_StartAbility_3500" === TAG || + "FreeInstall_Stage_Local_StartAbility_2000" === TAG) { + var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + globalThis.delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + } + + if ("FreeInstall_Stage_Local_StartAbility_2000" === TAG) { + var cmd5 = "bm uninstall -n com.ohos.hag.famanager"; + globalThis.delegator.executeShellCommand(cmd5, (err: any, d: any) => { + console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await sleep(500); + done(); + }); + + async function abilityForeground(tag) { + globalThis.delegator.doAbilityForeground(globalThis.ability, (err: any, data: any) => { + console.info(tag + "doAbilityForeground err: " + JSON.stringify(err) + ", data: " + JSON.stringify(data)); + }); + } + + async function abilityBackground(tag) { + globalThis.delegator.doAbilityBackground(globalThis.ability, (err: any, data: any) => { + console.info(tag + "abilityBackground err: " + JSON.stringify(err) + ", data: " + JSON.stringify(data)); + }); + } + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0100 + * @tc.name The deviceid passed in is null, so the installation free process is implemented + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0100", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0100-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0100"; + var flag = 0; + var str = { + "deviceId":"", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0100-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0200 + * @tc.name The passed in deviceid is empty, and the installed apps are automatically pulled up + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0200", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0200-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0200"; + var flag = 0; + abilityForeground(TAG); + await sleep(1000); + var str = { + "deviceId":"", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0200-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0300 + * @tc.name The deviceid passed in is empty. There is no need to install or installed HAP package + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0300", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0300-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0300"; + var cmd300 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd300, (err: any, d: any) => { + console.info("executeShellCommand300 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 4).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0300-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0400 + * @tc.name Do not transfer deviceid to realize installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0400", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0400-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0400"; + var flag = 0; + var cmd400 = "cp data/test/AtomizationStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + globalThis.delegator.executeShellCommand(cmd400, (err: any, d: any) => { + console.info("executeShellCommand400 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0400-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0500 + * @tc.name The installed application will be automatically pulled up without transmitting the deviceid + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0500", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0500-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0500"; + var flag = 0; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0500-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0600 + * @tc.name Manually obtain and pass in the deviceid of the device to realize the installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0600", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0600-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0600"; + var flag = 0; + var deviceId = ""; + abilityForeground(TAG); + await sleep(1000); + abilityManager.getTopAbility((err, data) => { + console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err)); + console.log(TAG + 'getTopAbility result deviceId:' + JSON.stringify(data.ability.deviceId)); + deviceId = data.ability.deviceId; + }) + await sleep(2000); + var str = { + "deviceId": deviceId, + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0600-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0700 + * @tc.name Manually obtain and pass in the deviceid of the device, + and the installed application will be automatically pulled up + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0700", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0700-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0700"; + var flag = 0; + var deviceId = ""; + abilityForeground(TAG); + await sleep(1000); + abilityManager.getTopAbility((err, data) => { + console.log(TAG + 'getTopAbility result: ' + JSON.stringify(data) + " , err: " + JSON.stringify(err)); + console.log(TAG + 'getTopAbility result deviceId:' + JSON.stringify(data.ability.deviceId)); + deviceId = data.ability.deviceId; + }) + await sleep(2000); + var str = { + "deviceId": deviceId, + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0700-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0800 + * @tc.name Without passing deviceid, pull up the HAP with the same bundlename and different + abilityname as the entry to realize the installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0800", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0800-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0800"; + var flag = 0; + var cmd800 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd800, (err: any, d: any) => { + console.info("executeShellCommand800 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd801 = "cp data/test/AtomizationStageHm2.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd801, (err: any, d: any) => { + console.info("executeShellCommand801 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hnm2", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0800-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_0900 + * @tc.name Do not transfer deviceid, use callback to realize installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_0900", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_0900-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_0900"; + var cmd900 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationStageHm2.hap"; + globalThis.delegator.executeShellCommand(cmd900, (err: any, d: any) => { + console.info("executeShellCommand900 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd901 = "cp data/test/AtomizationStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + globalThis.delegator.executeShellCommand(cmd901, (err: any, d: any) => { + console.info("executeShellCommand901 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str, (error, data) => { + console.log(TAG + ": startAbility err: " + JSON.stringify(error) + ",data: " + JSON.stringify(data)); + expect(error.code == 0).assertTrue(); + }) + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_0900-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1000 + * @tc.name Do not transmit deviceid, and use callback to automatically pull up installed applications + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1000", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1000-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1000"; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str, (error, data) => { + console.log(TAG + ": startAbility err: " + JSON.stringify(error) + ",data: " + JSON.stringify(data)); + expect(error.code == 0).assertTrue(); + }) + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1000-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1100 + * @tc.name Flags=1717 of the incoming error. There is a hap package that needs to + be installed free under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1100", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1100-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1100"; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": 1717, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 1).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1100-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1200 + * @tc.name Bad flags=1717 passed in, atomized HAP package installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1200", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1200-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1200"; + var flag = 0; + var cmd1200 = "bm install -p data/test/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd1200, (err: any, d: any) => { + console.info("executeShellCommand1200 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": 1717, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1200-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1300 + * @tc.name Flags= '94.31' of the incoming error. There is a hap package that + needs to be installed free under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1300", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1300-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1300"; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": '94.31', + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 1).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1300-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1400 + * @tc.name Flags= '94.31' of incoming error, atomized HAP package installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1400", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1400-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1400"; + var flag = 0; + var cmd1400 = "bm install -p data/test/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd1400, (err: any, d: any) => { + console.info("executeShellCommand1400 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": '94.31', + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1400-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1500 + * @tc.name Flags= '' of the incoming error. There is a hap package that needs to be + installed under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1500", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1500-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1500"; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": '', + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 1).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1500-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1600 + * @tc.name Bad flags= ', atomized HAP package installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1600", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1600-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1600"; + var flag = 0; + var cmd1600 = "bm install -p data/test/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd1600, (err: any, d: any) => { + console.info("executeShellCommand1600 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": '', + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1600-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1700 + * @tc.name No flag is transmitted, and there are HAP packages that need to be installed under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1700", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1700-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1700"; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 1).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1700-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1800 + * @tc.name No flag is transmitted, and the atomized HAP package is installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1800", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1800-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1800"; + var flag = 0; + var cmd1800 = "bm install -p data/test/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd1800, (err: any, d: any) => { + console.info("executeShellCommand1800 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1800-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2100 + * @tc.name The parameters field is passed in the want to realize the installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2100", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2100-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2100"; + var flag = 0; + abilityForeground(TAG); + await sleep(1000); + + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + "parameters": { + "name": "1111", + "Ext2": "ExtValue2", + "site": "很开心看到你!" + } + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2100-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2200 + * @tc.name The parameters field is passed in the want, and the installed applications + are automatically pulled up + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2200", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2200-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2200"; + var flag = 0; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + "parameters": { + "name": "1111", + "Ext2": "ExtValue2", + "site": "很开心看到你!" + } + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2200-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2300 + * @tc.name Make the current service not in the foreground, and there are HAP + packages that need not be installed under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2300", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2300-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2300"; + abilityForeground(TAG); + await sleep(1000); + abilityBackground(TAG); + await sleep(5000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 13).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2300-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2400 + * @tc.name The current service is not in the foreground, and the atomized HAP package has been installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2400", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2400-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2400"; + var cmd2400 = "bm install -p data/test/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd2400, (err: any, d: any) => { + console.info("executeShellCommand2400 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + abilityBackground(TAG); + await sleep(5000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 13).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2400-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2500 + * @tc.name FA Service Center installation free timeout + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2500", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2500-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2500"; + var installFACmd = "bm install -p data/test/MockServiceTimeout.hap"; + globalThis.delegator.executeShellCommand(installFACmd, (err: any, d: any) => { + console.info("executeShellCommand2500 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var mkdirEntryCmd = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + globalThis.delegator.executeShellCommand(mkdirEntryCmd, (err: any, d: any) => { + console.info("executeShellCommand2501 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var mkdirFilesCmd = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(mkdirFilesCmd, (err: any, d: any) => { + console.info("executeShellCommand2502 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var moveQianyiCmd = "cp data/test/AtomizationStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/" + + "haps/entry/files"; + globalThis.delegator.executeShellCommand(moveQianyiCmd, (err: any, d: any) => { + console.info("executeShellCommand2503 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 3).assertTrue(); + }); + await sleep(35000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2500-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_3000 + * @tc.name There are hapa and hapb with the same bundlename and abilityname and different modulenames. + Under the specified path, there are hapa with correct input parameters that need not be installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_3000", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_3000-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_3000"; + var flag = 0; + var installFACmd = "bm install -p data/test/MockService.hap"; + globalThis.delegator.executeShellCommand(installFACmd, (err: any, d: any) => { + console.info("executeShellCommand3003 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var mkdirEntryCmd = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + globalThis.delegator.executeShellCommand(mkdirEntryCmd, (err: any, d: any) => { + console.info("executeShellCommand3004 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var mkdirFilesCmd = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(mkdirFilesCmd, (err: any, d: any) => { + console.info("executeShellCommand3005 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3000 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd3000, (err: any, d: any) => { + console.info("executeShellCommand3000 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3001 = "cp data/test/AtomizationStageHm4.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd3001, (err: any, d: any) => { + console.info("executeShellCommand3001 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hm4", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_3000-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_3100 + * @tc.name There are hapa and hapb with the same bundlename and abilityname and different modulenames. + Hapb with input parameter error exists in the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_3100", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_3100-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_3100"; + var cmd3100 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationStageHm4.hap"; + globalThis.delegator.executeShellCommand(cmd3100, (err: any, d: any) => { + console.info("executeShellCommand3100 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3101 = "cp data/test/AtomizationStageHm2.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + globalThis.delegator.executeShellCommand(cmd3101, (err: any, d: any) => { + console.info("executeShellCommand3101 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.hm2.MainAbility", + "moduleName": "hm4", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 4).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_3100-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_3200 + * @tc.name Wrong modulename passed in + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_3200", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_3200-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_3200"; + var cmd3200 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationStageHm2.hap"; + globalThis.delegator.executeShellCommand(cmd3200, (err: any, d: any) => { + console.info("executeShellCommand3200 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3201 = "cp data/test/AtomizationStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + globalThis.delegator.executeShellCommand(cmd3201, (err: any, d: any) => { + console.info("executeShellCommand3201 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "hnm", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 1).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_3200-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_3300 + * @tc.name Do not transfer modulename. There are HAP packages that need not be + installed under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_3300", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_3300-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_3300"; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 1).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_3300-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_3400 + * @tc.name Modulename is not passed. Atomized HAP package is installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_3400", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_3400-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_3400"; + var flag = 0; + var cmd3400 = "bm install -p data/test/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd3400, (err: any, d: any) => { + console.info("executeShellCommand3400 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "deviceId": "", + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_3400-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_3500 + * @tc.name Service to pull up the service of the atomized service to realize the installation free process + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_3500", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_3500-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_3500"; + commonEvent.createSubscriber(subscribeInfo, CreateSubscriberCallBack); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.open.harmony.packagemag", + "abilityName": "com.open.harmony.packagemag.ServiceAbility", + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + expect(result).assertEqual("onSuccess"); + console.info("------------end FreeInstall_Stage_Local_StartAbility_3500-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_1900 + * @tc.name The current service is not in the foreground. Page a jumps to page B first. + There are HAP packages that need not be installed under the specified path + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_1900", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_1900-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_1900"; + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.open.harmony.packagemag", + "abilityName": "MainAbility1", + "moduleName": "entry", + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": Mainability2 startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": Mainability2 startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(5000); + abilityBackground(TAG); + await sleep(1000); + var str2 = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str2).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 13).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_1900-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2000 + * @tc.name The current service is not in the foreground. Page a jumps to page B first. + The atomized HAP package has been installed + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2000", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2000-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2000"; + var cmd2000 = "bm install -p data/test/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd2000, (err: any, d: any) => { + console.info("executeShellCommand2000 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.open.harmony.packagemag", + "abilityName": "MainAbility1", + "moduleName": "entry", + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": Mainability2 startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": Mainability2 startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(5000); + abilityBackground(TAG); + await sleep(1000); + var str2 = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str2).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + expect(error.code == 13).assertTrue(); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2000-------------"); + done(); + }); + + console.info("-------------Stage model--> startAbilityXTS Test end----------------") + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.css b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.css new file mode 100644 index 0000000000000000000000000000000000000000..e0401b1a794ee2da03d43690123e976b7b98e780 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.css @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2022 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. + */ + +#wrapper { + flex-direction: column; +} + +#div1 { + width: 100%; + height: 100%; + justify-content: center; + align-items: center; + background-color: white; +} + +#text1 { + height: 45px; + width: 150px; + font-size: 16px; + text-align: center; +} + diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.hml b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.hml new file mode 100644 index 0000000000000000000000000000000000000000..b01936fb18990555228d425ea5860c785862aa50 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.hml @@ -0,0 +1,7 @@ +
+
+
+ {{title}} +
+
+
\ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.json new file mode 100644 index 0000000000000000000000000000000000000000..1c9e2ce993cf9193502ea0a014beb511aac12a73 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/js/ServiceAbility/pages/index/index.json @@ -0,0 +1,6 @@ +{ + "actions": {}, + "data": { + "title": "Hello World" + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..07b378b1f951143a31af615e8069c8d28e4697bc --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/module.json @@ -0,0 +1,73 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.open.harmony.packagemag.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + }, + { + "name": "MainAbility1", + "srcEntrance": "./ets/MainAbility1/MainAbility1.ts", + "description": "$string:MainAbility1_desc", + "icon": "$media:icon", + "label": "$string:MainAbility1_label" + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED" + }, + { + "name": "ohos.permission.GET_BUNDLE_INFO" + }, + { + "name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE" + }, + { + "name": "ohos.permission.DISTRIBUTED_DATASYNC" + } + ], + "extensionAbilities": [ + { + "name": "com.open.harmony.packagemag.ServiceAbility", + "srcEntrance": "./ets/ServiceAbility/ServiceAbility.ts", + "label": "$string:form_ServiceAbility_label", + "description": "$string:form_ServiceAbility_desc", + "type": "service", + "metadata": [ + { + "name": "ohos.extension.form", + "resource": "$profile:form_config" + } + ] + } + ] + } + } \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..fd38366e0edaa08108cc76d149a789ee9bf31609 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + }, + { + "name": "MainAbility1_desc", + "value": "description" + }, + { + "name": "MainAbility1_label", + "value": "label" + }, + { + "name": "form_FormAbility_desc", + "value": "form_description" + }, + { + "name": "form_FormAbility_label", + "value": "form_label" + }, + { + "name": "form_ServiceAbility_desc", + "value": "form_description" + }, + { + "name": "form_ServiceAbility_label", + "value": "form_label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/profile/form_config.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/profile/form_config.json new file mode 100644 index 0000000000000000000000000000000000000000..710d66b9ef0931b723c84d4536c9ac7231f74afd --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/profile/form_config.json @@ -0,0 +1,42 @@ +{ + "forms": [ + { + "isDefault": true, + "src": "./js/ServiceAbility/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "ServiceAbility", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + }, + { + "isDefault": true, + "src": "./js/ServiceAbility/pages/index/index", + "scheduledUpdateTime": "10:30", + "defaultDimension": "2*2", + "name": "ServiceAbility", + "description": "This is a service widget.", + "colorMode": "auto", + "window": { + "designWidth": 720, + "autoDesignWidth": true + }, + "formConfigAbility": "ability://xxxxx", + "supportDimensions": [ + "2*2" + ], + "updateEnabled": true, + "updateDuration": 1 + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..895c316edeb177235d0d7d5af4a944134ac5be10 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,6 @@ +{ + "src": [ + "pages/index", + "pages/second" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/freeinstallstartabilitystagetest/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..39ae7839606a167d360d8f238c6bf7f4089afeff --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.open.harmony.packagemag.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..78feb0e99126c54ed800e99702fe141cd952bfdd --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "StartNoTargetBundleListXTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..fae9ebc7dcf6097147b5e5c92006e71b35c66038 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("StageMyApplication1") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":stagemyapplication1_js_assets", + ":stagemyapplication1_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "StageMyApplication1" +} + +ohos_app_scope("stagemyapplication1_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("stagemyapplication1_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("stagemyapplication1_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":stagemyapplication1_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/Test.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..ae9a6b889fefe23bb53be0b57b45e6ccf619d3e1 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/Test.json @@ -0,0 +1,3 @@ +{ + "description": "Configuration for hjunit demo Tests", +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..1e29b8b56f5d88da231bf45e2e0a093ff4d8961d --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + + windowStage.setUIContent(this.context, "pages/index", null) + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..089639cdedb287dce6f1238f92865d522a72c7c8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/ets/pages/index.ets @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +@Entry +@Component +struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..85af6ede85105ff19afa4698bdef7b07fdd4a3a2 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "myapplication1", + "type": "feature", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:myapplication1_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": true, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..e3e849ee297630243c1807d3f99e196172b7e5de --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "myapplication1_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/stagemyapplication1/signature/openharmony_sx.p7b differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/app.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..39ae7839606a167d360d8f238c6bf7f4089afeff --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/app.json @@ -0,0 +1,20 @@ +{ + "app": { + "bundleName": "com.open.harmony.packagemag.hmservice", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name", + "description": "description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..78feb0e99126c54ed800e99702fe141cd952bfdd --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "StartNoTargetBundleListXTS" + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/AppScope/resources/base/media/app_icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/BUILD.gn b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..bf71f89abdb435398f7f9192c6ac99c401995246 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2022 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("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("StartAbilityNoTargetBundleListStageTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":startabilitynotargetbundleliststagetest_js_assets", + ":startabilitynotargetbundleliststagetest_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "StartAbilityNoTargetBundleListStageTest" +} + +ohos_app_scope("startabilitynotargetbundleliststagetest_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("startabilitynotargetbundleliststagetest_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("startabilitynotargetbundleliststagetest_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":startabilitynotargetbundleliststagetest_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/Test.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..4ea0bccf5471f5a53169ee57eea82a9626e5cbf8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/Test.json @@ -0,0 +1,34 @@ +{ + "description": "Configuration for startabilitynotargetbundleliststagetest Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.open.harmony.packagemag.hmservice", + "module-name": "entry", + "shell-timeout": "600000" + }, + "kits": [ + { + "test-file-name": [ + "StartAbilityNoTargetBundleListStageTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }, + { + "type": "ShellKit", + "run-command": [ + "remount", + "mkdir /data/test/" + ] + }, + { + "type": "PushKit", + "push":[ + "AtomizationStageEntry.hap -> /data/test/AtomizationStageEntry.hap", + "MockService.hap -> /data/test/MockService.hap", + "StageMyApplication1.hap -> /data/test/StageMyApplication1.hap" + ] + } + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/Application/AbilityStage.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..b3f3c306081d07be09d4367c3aa27b13cf57f046 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2022 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 AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..9dca45fbb5d2120f45d00a5c542d6ca4139a5e12 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want, launchParam) { + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate") + windowStage.setUIContent(this.context, "pages/index", null) + globalThis.abilityContext = this.context; + } + + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..2c446f687cce0ed2e023e32461014af624e1ab01 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -a' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + globalThis.delegator = abilityDelegator; + + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/pages/index.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..39d608703153cd07de7a2f4418f2da7c5f4e85da --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/pages/index.ets @@ -0,0 +1,57 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets" +import file from '@system.file'; +import List from '../test/ListTest' + +@Entry +@Component +struct Index { + @State message: string = 'StartAbility NoTargetBundleList Test' + aboutToAppear() { + console.info("start run testcase!!!!") + const core = Core.getInstance() + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }) + core.addService('expect', expectExtend) + const reportExtend = new ReportExtend(file) + + core.addService('report', reportExtend) + core.init() + globalThis.abilityWant.parameters.timeout = 20000; + core.subscribeEvent('task', reportExtend) + const configService = core.getDefaultService('config') + console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters)) + configService.setConfig(globalThis.abilityWant.parameters) + List(globalThis.abilityContext) + core.execute() + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/test/ListTest.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/test/ListTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..cdbb0f8cc4e70ab6e05607cc707be08528a01209 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/test/ListTest.ets @@ -0,0 +1,20 @@ +/** + * Copyright (c) 2022 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 startAbilityTest from './StartAbilityTest' + +export default function testsuite(context) { + startAbilityTest(context) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/test/StartAbilityTest.ets b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/test/StartAbilityTest.ets new file mode 100644 index 0000000000000000000000000000000000000000..804ca44a6c8310c5309007972ea491b0fb73c20f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/ets/test/StartAbilityTest.ets @@ -0,0 +1,205 @@ +// @ts-nocheck + +/** + * Copyright (c) 2022 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 "deccjsunit/index" +import ability from '@ohos.application.Ability' +import rpc from '@ohos.rpc'; +import wantConstant from '@ohos.ability.wantConstant' +import Prompt from '@system.prompt'; +import abilityManager from '@ohos.application.abilityManager'; + +export default function startAbilityTest(abilityContext) { + + describe('startAbilityTest', function () { + + console.info("-------------Stage model--> startNoTargetBundleListXTS Test start----------------") + + var TAG = ""; + + globalThis.delegator.getCurrentTopAbility((err: any, data: any) => { + console.info("getCurrentTopAbility err: " + JSON.stringify(err) + ", data: " + JSON.stringify(data)); + globalThis.ability = data; + }); + + + function sleep(time) { + return new Promise((resolve) => setTimeout(resolve, time)) + } + + beforeAll(async function (done) { + console.info("StartAbilityTest before all called"); + var cmd = "bm install -p data/test/MockService.hap"; + console.info("cmd : " + cmd) + globalThis.delegator.executeShellCommand(cmd, (err: any, d: any) => { + console.info("executeShellCommand : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd1 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry"; + globalThis.delegator.executeShellCommand(cmd1, (err: any, d: any) => { + console.info("executeShellCommand1 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2 = "mkdir -p /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd2, (err: any, d: any) => { + console.info("executeShellCommand2 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd3 = "cp data/test/AtomizationStageEntry.hap /data/app/el2/100/base/com.ohos.hag.famanager/haps/" + + "entry/files"; + globalThis.delegator.executeShellCommand(cmd3, (err: any, d: any) => { + console.info("executeShellCommand3 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + done(); + }) + }); + + afterEach(async function (done) { + console.info("StartAbilityTest after each called"); + if ("FreeInstall_Stage_Local_StartAbility_2700" === TAG) { + var cmd4 = "bm uninstall -n com.example.qianyiyingyong.hmservice"; + globalThis.delegator.executeShellCommand(cmd4, (err: any, d: any) => { + console.info("executeShellCommand4 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + } + + if ("FreeInstall_Stage_Local_StartAbility_2800" === TAG) { + var cmd5 = "bm uninstall -n com.ohos.hag.famanager"; + globalThis.delegator.executeShellCommand(cmd5, (err: any, d: any) => { + console.info("executeShellCommand5 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + } + await sleep(500); + done(); + }); + + async function abilityForeground(tag) { + globalThis.delegator.doAbilityForeground(globalThis.ability, (err: any, data: any) => { + console.info(tag + "doAbilityForeground err:" + JSON.stringify(err) + ", data:" + JSON.stringify(data)); + }); + } + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2600 + * @tc.name Atomized services are not added to the white list, and cross application installation + is not required + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2600", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2600-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2600"; + var flag = 0; + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2600-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2700 + * @tc.name Atomized services are not added to the white list, + and atomized HAP packages are pulled across applications + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2700", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2700-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2700"; + var flag = 0; + var cmd2700 = "bm install -p data/test/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd2700, (err: any, d: any) => { + console.info("executeShellCommand2700 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.example.qianyiyingyong.hmservice", + "abilityName": "com.example.qianyiyingyong.MainAbility", + "moduleName": "entry", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2700-------------"); + done(); + }); + + /* + * @tc.number FreeInstall_Stage_Local_StartAbility_2800 + * @tc.name Atomized services are not added to the white list, + same application pull up the different ability. + * @tc.desc Function test + * @tc.level 0 + */ + it("FreeInstall_Stage_Local_StartAbility_2800", 0, async function (done) { + console.info("------------start FreeInstall_Stage_Local_StartAbility_2800-------------"); + TAG = "FreeInstall_Stage_Local_StartAbility_2800"; + var flag = 0; + var cmd2800 = "rm /data/app/el2/100/base/com.ohos.hag.famanager/haps/entry/files/AtomizationStageEntry.hap"; + globalThis.delegator.executeShellCommand(cmd2800, (err: any, d: any) => { + console.info("executeShellCommand2800 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + var cmd2801 = "cp data/test/StageMyApplication1.hap /data/app/el2/100/base/com.ohos.hag.famanager" + + "/haps/entry/files"; + globalThis.delegator.executeShellCommand(cmd2801, (err: any, d: any) => { + console.info("executeShellCommand2801 : err : " + JSON.stringify(err), " data : " + JSON.stringify(d)); + }) + await sleep(500); + abilityForeground(TAG); + await sleep(1000); + var str = { + "bundleName": "com.open.harmony.packagemag.hmservice", + "abilityName": "MainAbility", + "moduleName": "myapplication1", + "flags": wantConstant.Flags.FLAG_INSTALL_ON_DEMAND, + } + abilityContext.startAbility(str).then((data) => { + console.log(TAG + ": startAbility success. data: " + JSON.stringify(data)); + flag = 1; + expect(flag == 1).assertTrue(); + }).catch((error) => { + console.log(TAG + ": startAbility fail. err: " + JSON.stringify(error)); + + }); + await sleep(2000); + console.info("------------end FreeInstall_Stage_Local_StartAbility_2800-------------"); + done(); + }); + + console.info("-------------Stage model--> startNoTargetBundleListXTS Test end----------------") + }) +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/module.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..93a744ea7a2a64d1d1f115e06cad1e79ab8677b8 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/module.json @@ -0,0 +1,37 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:entry_desc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "uiSyntax": "ets", + "abilities": [ + { + "name": "com.open.harmony.packagemag.hmservice.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:MainAbility_desc", + "icon": "$media:icon", + "label": "$string:MainAbility_label", + "visible": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..490210a3908f47722dc942d49dacc98b97669a5f --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_desc", + "value": "description" + }, + { + "name": "MainAbility_desc", + "value": "description" + }, + { + "name": "MainAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/media/icon.png differ diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..feec276e105eeb8d621c20aaf838f318b0a94150 --- /dev/null +++ b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/index" + ] +} diff --git a/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/signature/openharmony_sx.p7b b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..66b4457a8a81fb8d3356cf46d67226c850944858 Binary files /dev/null and b/ability/ability_runtime/freeinstalltest/startabilitystagetest/startabilitynotargetbundleliststagetest/signature/openharmony_sx.p7b differ