diff --git a/ability/ability_runtime/stage/actsuripermission/BUILD.gn b/ability/ability_runtime/stage/actsuripermission/BUILD.gn index 624d53faaf68e90ba5e5777a513531af24ef0cc0..5220445ff86458bb9c5df916f4dd95ae564904d9 100755 --- a/ability/ability_runtime/stage/actsuripermission/BUILD.gn +++ b/ability/ability_runtime/stage/actsuripermission/BUILD.gn @@ -19,7 +19,6 @@ group("ActsUriPermission") { deps = [ "actsassistanthap:ActsAssistantHap", "actsassistanthap:ActsAssistantHap4", - "actsassistanthap2:ActsAssistantHap2", "actsfasupporturi:ActsFaSupportUri", "actstempuripermissionhaptest:ActsTempUriPermissionHapTest", ] diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap/entry/src/main/ets/Hap2MainAbility1/Hap2MainAbility1.ts b/ability/ability_runtime/stage/actsuripermission/actsassistanthap/entry/src/main/ets/Hap2MainAbility1/Hap2MainAbility1.ts index b27a08ed82f553741ce9d431605451035c96690a..aca4e5c978ac51fe57b591d996615b8c60353471 100755 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap/entry/src/main/ets/Hap2MainAbility1/Hap2MainAbility1.ts +++ b/ability/ability_runtime/stage/actsuripermission/actsassistanthap/entry/src/main/ets/Hap2MainAbility1/Hap2MainAbility1.ts @@ -30,12 +30,6 @@ export default class Hap2MainAbility1 extends Ability { onDestroy() { console.log('[Demo] Hap2MainAbility1 onDestroy') - if (caseNumber === 16) { - let eventName : string = 'TerminateNotify_Hap3MainAbility1'; - commonEvent.publish(eventName, (err) => { - console.log('Hap2MainAbility1' + eventName); - }); - } } onWindowStageCreate(windowStage) { @@ -346,58 +340,6 @@ export default class Hap2MainAbility1 extends Ability { break; } - case 16: { - console.log('[Demo] Hap2MainAbility1 case 16 call.'); - let eventName : string = 'RevicedFrom_Hap3MainAbility1'; - let subscribeInfo16_1 = { - events: [eventName] - } - let subscriber16_1; - function UnSubscribeInfoCallback16_1(err, data) { - console.info("Hap2MainAbility1 ===UnSubscribeInfoCallback16_1===") - } - - function SubscribeCallBackContext16_1(err, data) { - console.log('Hap2MainAbility1 Subscribe CallBack data:' + JSON.stringify(data)); - caseNumber = 16; - if (data.event === eventName) { - commonEvent.unsubscribe(subscriber16_1, UnSubscribeInfoCallback16_1) - globalThis.hap2MainAbility1Context.terminateSelf(); - } - } - - commonEvent.createSubscriber(subscribeInfo16_1).then(async (data) => { - subscriber16_1 = data; - console.debug('====>Create Subscriber====>'); - await commonEvent.subscribe(subscriber16_1, SubscribeCallBackContext16_1); - }); - - let filePath : string = this.context.filesDir + '/test_ability1_2.txt'; - fs.open(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE, (err, file) => { - if (err) { - console.info('mkdir failed with error message: ' + err.message + ', error code: ' + err.code); - } else { - console.info('Hap2MainAbility1 file created, fd: ' + file.fd); - } - }); - let uri : string = fileUri.getUriFromPath(filePath); - console.info('[Demo] Hap2MainAbility1 uri is ' + JSON.stringify(uri)); - - let want = { - flags : wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, - bundleName : 'com.example.timeout', - abilityName : 'Hap3MainAbility1', - uri : uri - } - this.context.startAbility(want).then(() => { - console.log('TAG + startAbility succeed'); - }).catch((error) => { - console.log('error.code: ' + JSON.stringify(error.code) + ' error.message: ' + - JSON.stringify(error.message)); - }); - break; - } - case 17: { console.log('[Demo] Hap2MainAbility1 case 17 call.'); let uri : string = globalThis.abilityWant1.uri; diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/app.json b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/app.json deleted file mode 100644 index 67c915b0c2c5a3d3e1279421e38e096eb1d3eb7c..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/app.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "app": { - "bundleName": "com.example.timeout", - "vendor": "huawei", - "versionCode": 1000000, - "versionName": "1.0.0", - "debug": false, - "icon": "$media:icon", - "label": "$string:app_name", - "description": "$string:description_application", - "distributedNotificationEnabled": true, - "keepAlive": true, - "singleUser": true, - "minAPIVersion": 9, - "targetAPIVersion": 9, - "car": { - "apiCompatibleVersion": 9, - "singleUser": false - } - } -} diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/resources/base/element/string.json b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/resources/base/element/string.json deleted file mode 100644 index eaa7668e18a4f3384336be0c0ef62f229bbd2aab..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string":[ - { - "name":"app_name", - "value":"UriPermissionAssistanthap2Test" - } - ] -} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/resources/base/media/app_icon.png b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/resources/base/media/app_icon.png deleted file mode 100644 index 474a55588fd7216113dd42073aadf254d4dba023..0000000000000000000000000000000000000000 Binary files a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/AppScope/resources/base/media/app_icon.png and /dev/null differ diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/BUILD.gn b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/BUILD.gn deleted file mode 100644 index a72547d493edc96e9e107591e663e9b6a320ff16..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/BUILD.gn +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//test/xts/tools/build/suite.gni") - -ohos_hap_assist_suite("ActsAssistantHap2") { - hap_name = "ActsAssistantHap2" - js_build_mode = "debug" - hap_profile = "entry/src/main/module.json" - - testonly = true - deps = [ - ":actsassistanthap2_js_assets", - ":actsassistanthap2_resources", - ] - ets2abc = true - certificate_profile = "signature/openharmony_sx.p7b" - - subsystem_name = "ability" - part_name = "ability_runtime" -} - -ohos_app_scope("actsassistanthap2_app_profile") { - app_profile = "AppScope/app.json" - sources = [ "AppScope/resources" ] -} - -ohos_js_assets("actsassistanthap2_js_assets") { - source_dir = "entry/src/main/ets" -} - -ohos_resources("actsassistanthap2_resources") { - sources = [ "entry/src/main/resources" ] - deps = [ ":actsassistanthap2_app_profile" ] - hap_profile = "entry/src/main/module.json" -} diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/ets/Hap3MainAbility1/Hap3MainAbility1.ts b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/ets/Hap3MainAbility1/Hap3MainAbility1.ts deleted file mode 100644 index 203a29a95c58e984e8ab27608a73a07971e5094d..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/ets/Hap3MainAbility1/Hap3MainAbility1.ts +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import Ability from '@ohos.app.ability.UIAbility' -import commonEvent from '@ohos.commonEvent'; -import fs from '@ohos.file.fs' - -function sleep(time) { - return new Promise((resolve) => setTimeout(resolve, time)) -} - -export default class Hap3MainAbility1 extends Ability { - onCreate(want, launchParam) { - console.log('[Demo] Hap3MainAbility1 onCreate') - globalThis.abilityWant = want; - } - - onDestroy() { - console.log('[Demo] Hap3MainAbility1 onDestroy') - } - - onWindowStageCreate(windowStage) { - console.log('[Demo] Hap3MainAbility1 onWindowStageCreate') - windowStage.setUIContent(this.context, 'pages/Hap3MainAbility1_pages', null) - } - - onWindowStageDestroy() { - console.log('[Demo] Hap3MainAbility1 onWindowStageDestroy') - } - - onForeground() { - console.log('[Demo] Hap3MainAbility1 onForeground') - let eventName : string = 'TerminateNotify_Hap3MainAbility1'; - let subscribeInfo = { - events: [eventName] - } - let subscriber_1; - function UnSubscribeInfoCallback_1(err, data) { - console.info("Hap2MainAbility1 ===UnSubscribeInfoCallback_1===") - } - - async function SubscribeCallBackContext(err, data) { - console.log('Hap3MainAbility1 Subscribe CallBack data:' + JSON.stringify(data)); - if (data.event === eventName) { - await sleep(1000); - let uri : string = globalThis.abilityWant.uri; - if (uri == null) { - console.log('[Demo] Hap3MainAbility1 uri is invalid'); - return; - } - console.info('[Demo] Hap3MainAbility1 uri is ' + JSON.stringify(uri)); - let eventName13_1 : string = 'Temp_UriPermissionTest_1300_Read_Successfully'; - let eventName13_2 : string = 'Temp_UriPermissionTest_1300_Read_Failed'; - fs.open(uri, fs.OpenMode.READ_ONLY).then((file) => { - console.info('file fd: ' + file.fd); - commonEvent.publish(eventName13_1, (err) => { - console.log('Hap3MainAbility1' + eventName13_1); - }); - }).catch((err) => { - console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code); - commonEvent.publish(eventName13_2, (err) => { - console.log('Hap3MainAbility1' + eventName13_2); - }); - }); - - let eventName13_3 : string = 'Temp_UriPermissionTest_1300_Write_Successfully'; - let eventName13_4 : string = 'Temp_UriPermissionTest_1300_Write_Failed'; - fs.open(uri, fs.OpenMode.READ_WRITE).then((file) => { - console.info('file fd: ' + file.fd); - commonEvent.publish(eventName13_3, (err) => { - console.log('Hap3MainAbility1' + eventName13_3); - }); - }).catch((err) => { - console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code); - commonEvent.publish(eventName13_4, (err) => { - console.log('Hap3MainAbility1' + eventName13_4); - }); - }); - } - commonEvent.unsubscribe(subscriber_1, UnSubscribeInfoCallback_1) - } - - commonEvent.createSubscriber(subscribeInfo).then(async (data) => { - subscriber_1 = data; - console.debug('====>Create Subscriber====>'); - await commonEvent.subscribe(subscriber_1, SubscribeCallBackContext); - }); - - let eventName1 : string = 'RevicedFrom_Hap3MainAbility1'; - commonEvent.publish(eventName1, (err) => { - console.log('Hap3MainAbility1' + eventName1); - }); - } - - onBackground() { - console.log('[Demo] Hap3MainAbility1 onBackground') - } -}; diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/ets/pages/Hap3MainAbility1_pages.ets b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/ets/pages/Hap3MainAbility1_pages.ets deleted file mode 100644 index 29e00381572dbc48a3e3e83574d4f38ada35ae8f..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/ets/pages/Hap3MainAbility1_pages.ets +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -@Entry -@Component -struct Hap3MainAbility1_pages { - @State message: string = 'Hap3MainAbility1' - - 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/stage/actsuripermission/actsassistanthap2/entry/src/main/module.json b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/module.json deleted file mode 100644 index 31a300dd177f1cf602655af808a59f756de7461b..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/module.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "module": { - "name": "hap3", - "type": "feature", - "description": "$string:hap3_desc", - "mainElement": "MainAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "uiSyntax": "ets", - "pages": "$profile:main_pages", - "abilities": [ - { - "name": "Hap3MainAbility1", - "srcEntrance": "./ets/Hap3MainAbility1/Hap3MainAbility1.ts", - "description": "$string:Hap3MainAbility1_desc", - "icon": "$media:icon", - "label": "$string:Hap3MainAbility1_label", - "visible": true, - "orientation": "portrait" - } - ] - } -} \ No newline at end of file diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/element/string.json b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/element/string.json deleted file mode 100644 index 6332cc752c9000d4e8c8b70697fe72a20a2c8ec9..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "string": [ - { - "name": "description_application", - "value": "demo for test" - }, - { - "name": "hap3_desc", - "value": "description" - }, - { - "name": "Hap3MainAbility1_desc", - "value": "description" - }, - { - "name": "Hap3MainAbility1_label", - "value": "label" - } - ] -} diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/media/icon.png b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index 474a55588fd7216113dd42073aadf254d4dba023..0000000000000000000000000000000000000000 Binary files a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/profile/main_pages.json b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index db22714743a92b79c32ca9ddd5aa4f36636f6b08..0000000000000000000000000000000000000000 --- a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Hap3MainAbility1_pages" - ] -} diff --git a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/signature/openharmony_sx.p7b b/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/signature/openharmony_sx.p7b deleted file mode 100755 index bd499b6ed83b287ba812221de658503b9c37d07a..0000000000000000000000000000000000000000 Binary files a/ability/ability_runtime/stage/actsuripermission/actsassistanthap2/signature/openharmony_sx.p7b and /dev/null differ diff --git a/ability/ability_runtime/stage/actsuripermission/actstempuripermissionhaptest/Test.json b/ability/ability_runtime/stage/actsuripermission/actstempuripermissionhaptest/Test.json index 89dacecba4619f6b1e18afe24ef4cab31cb82177..19678cbba89087995bc72a143b5447ffdac57861 100755 --- a/ability/ability_runtime/stage/actsuripermission/actstempuripermissionhaptest/Test.json +++ b/ability/ability_runtime/stage/actsuripermission/actstempuripermissionhaptest/Test.json @@ -13,7 +13,6 @@ "test-file-name": [ "ActsTempUriPermissionHapTest.hap", "ActsAssistantHap.hap", - "ActsAssistantHap2.hap", "ActsAssistantHap4.hap", "ActsFaSupportUri.hap" ], diff --git a/ability/ability_runtime/stage/actsuripermission/actstempuripermissionhaptest/entry/src/main/ets/test/UriPermissionTest.ets b/ability/ability_runtime/stage/actsuripermission/actstempuripermissionhaptest/entry/src/main/ets/test/UriPermissionTest.ets index a91b53460e3ea628ae29185239dc2f5f1b03e994..3aed28658091abfb55361c1eba169b54557bbd46 100755 --- a/ability/ability_runtime/stage/actsuripermission/actstempuripermissionhaptest/entry/src/main/ets/test/UriPermissionTest.ets +++ b/ability/ability_runtime/stage/actsuripermission/actstempuripermissionhaptest/entry/src/main/ets/test/UriPermissionTest.ets @@ -30,13 +30,22 @@ export default function UriPermissionTest() { done() }); + let abilityContext = globalThis.abilityContext; afterEach(async function (done) { console.info('UriPermissionTest after each called'); + let wantInfo = { + bundleName: 'com.example.stageautosign', + abilityName: 'com.example.stageautosign.MainAbility' + } + await abilityContext.startAbility(wantInfo).then(() => { + console.info('afterEach startAbility succeed'); + }).catch((error) => { + console.info('afterEach error.code: ' + JSON.stringify(error.code) + ' error.message: ' + + JSON.stringify(error.message)); + }); done(); }); - let abilityContext = globalThis.abilityContext; - function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)) } @@ -1362,97 +1371,6 @@ export default function UriPermissionTest() { console.info("---------------Temp_UriPermissionTest_1200 is end---------------") }); - /* - * @tc.number Temp_UriPermissionTest_1300 - * @tc.name The ability of HAP A grant uri permission to the ability of HAP B - * @tc.desc Function test - * @tc.level 0 - */ - it("Temp_UriPermissionTest_1300", 0, async function (done) { - console.info("---------------Temp_UriPermissionTest_1300 is start---------------") - let TAG13 = "Temp_UriPermissionTest_1300"; - let flag13_1 = false; - let flag13_2 = false; - let eventName13_1 : string = 'Temp_UriPermissionTest_1300_Read_Successfully'; - let eventName13_2 : string = 'Temp_UriPermissionTest_1300_Read_Failed'; - let subscribeInfo13_1 = { - events: [eventName13_1, eventName13_2] - } - let subscriber13_1; - function UnSubscribeInfoCallback13_1(err, data) { - console.info(TAG13 + "===UnSubscribeInfoCallback13_1===") - } - - function SubscribeCallBackContext13_1(err, data) { - console.info(TAG13 + ' Subscribe CallBack data:' + JSON.stringify(data)); - if (data.event === eventName13_1) { - console.info(TAG13 + 'read file succeed.'); - commonEvent.unsubscribe(subscriber13_1, UnSubscribeInfoCallback13_1) - flag13_1 = true; - } - if (data.event === eventName13_2) { - console.info(TAG13 + 'read file failed.'); - expect().assertFail(); - } - } - - commonEvent.createSubscriber(subscribeInfo13_1).then(async (data) => { - subscriber13_1 = data; - console.info('====>Create subscriber13_1====>'); - await commonEvent.subscribe(subscriber13_1, SubscribeCallBackContext13_1); - }); - - let eventName13_3 : string = 'Temp_UriPermissionTest_1300_Write_Successfully'; - let eventName13_4 : string = 'Temp_UriPermissionTest_1300_Write_Failed'; - let subscribeInfo13_2 = { - events: [eventName13_3, eventName13_4] - } - let subscriber13_2; - function UnSubscribeInfoCallback13_2(err, data) { - console.info(TAG13 + "===UnSubscribeInfoCallback13_2===") - } - - function SubscribeCallBackContext13_2(err, data) { - console.info(TAG13 + ' Subscribe CallBack data:' + JSON.stringify(data)); - if (data.event === eventName13_3) { - console.info(TAG13 + 'write file succeed.'); - expect().assertFail(); - } - if (data.event === eventName13_4) { - console.info(TAG13 + 'write file failed.'); - commonEvent.unsubscribe(subscriber13_2, UnSubscribeInfoCallback13_2) - flag13_2 = true; - } - } - - commonEvent.createSubscriber(subscribeInfo13_2).then(async (data) => { - subscriber13_2 = data; - console.info('====>Create subscriber13_2====>'); - await commonEvent.subscribe(subscriber13_2, SubscribeCallBackContext13_2); - }); - - let want = { - bundleName : "com.acts.authorizeduriapplication", - abilityName : "Hap2MainAbility1", - parameters : { - 'number' : 16 - } - } - await abilityContext.startAbility(want).then(() => { - console.info(TAG13 + ' startAbility succeed'); - }).catch((error) => { - console.info(TAG13 + 'error.code: ' + JSON.stringify(error.code) + ' error.message: ' + - JSON.stringify(error.message)); - }); - while (!flag13_1 || !flag13_2) { - console.info(TAG13 + 'waiting callback'); - await sleep(1000); - } - - done() - console.info("---------------Temp_UriPermissionTest_1300 is end---------------") - }); - /* * @tc.number Temp_UriPermissionTest_1400 * @tc.name The ability of HAP A grant uri permission to the ability of HAP B