未验证 提交 3b5030bf 编写于 作者: O openharmony_ci 提交者: Gitee

!8455 增加URI临时授权xts

Merge pull request !8455 from 于文泽/uri
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2021-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
......@@ -22,6 +22,7 @@ group("stage") {
"actslifecyclemultihap3:ActsLifecycleMultiHap3",
"actslifecyclemultihaptest:ActsLifecycleMultiHapTest",
"actslifecyclesinglehaptest:ActsLifecycleSingleHapTest",
"actsuripermission:ActsUriPermission",
"actswindowstagelifecyclemultihaptest:ActsWindowStageLifecycleMultiHapTest",
"actswindowstagelifecyclesinglehaptest:ActsWindowStageLifecycleSingleHapTest",
]
......
# 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")
group("ActsUriPermission") {
testonly = true
if (is_standard_system) {
deps = [
"actsassistanthap:ActsAssistantHap",
"actsassistanthap:ActsAssistantHap4",
"actsassistanthap2:ActsAssistantHap2",
"actsfasupporturi:ActsFaSupportUri",
"actstempuripermissionhaptest:ActsTempUriPermissionHapTest",
]
}
}
{
"app": {
"bundleName": "com.acts.authorizeduriapplication",
"vendor": "acts",
"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
}
}
}
{
"string":[
{
"name":"app_name",
"value":"UriPermissionAssistanthapTest"
}
]
}
\ No newline at end of file
# 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("ActsAssistantHap") {
hap_name = "ActsAssistantHap"
js_build_mode = "debug"
testonly = true
hap_profile = "entry/src/main/module.json"
deps = [
":actsassistanthap_js_assets",
":actsassistanthap_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actsassistanthap_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsassistanthap_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsassistanthap_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsassistanthap_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
ohos_hap_assist_suite("ActsAssistantHap4") {
hap_name = "ActsAssistantHap4"
js_build_mode = "debug"
testonly = true
hap_profile = "hap4/src/main/module.json"
deps = [
":actsassistanthap4_js_assets",
":actsassistanthap4_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("actsassistanthap4_js_assets") {
source_dir = "hap4/src/main/ets"
}
ohos_resources("actsassistanthap4_resources") {
sources = [ "hap4/src/main/resources" ]
deps = [ ":actsassistanthap_app_profile" ]
hap_profile = "hap4/src/main/module.json"
}
/*
* 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';
export default class Hap2MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log('[Demo] Hap2MainAbility2 onCreate')
globalThis.abilityWant2 = want;
}
onDestroy() {
console.log('[Demo] Hap2MainAbility2 onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('[Demo] Hap2MainAbility2 onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/Hap2MainAbility2_pages', null)
}
onWindowStageDestroy() {
console.log('[Demo] Hap2MainAbility2 onWindowStageDestroy')
}
onNewWant(want, launchParams) {
globalThis.abilityWant2 = want;
}
onForeground() {
console.log('[Demo] Hap2MainAbility2 onForeground')
switch (globalThis.abilityWant2.parameters['number']) {
case 20: {
let uri : string = globalThis.abilityWant2.uri;
if (uri == null) {
console.log('[Demo] Hap2MainAbility2 uri is invalid');
return;
}
let eventName20_1 : string = 'Temp_UriPermissionTest_0200_Read_Successfully';
let eventName20_2 : string = 'Temp_UriPermissionTest_0200_Read_Failed';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_ONLY).then((file) => {
console.info('read file fd: ' + file.fd);
commonEvent.publish(eventName20_1, (err) => {
console.log('Hap2MainAbility2' + eventName20_1);
});
}).catch((err) => {
console.info('read open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName20_2, (err) => {
console.log('Hap2MainAbility2' + eventName20_2);
});
});
let eventName20_3 : string = 'Temp_UriPermissionTest_0200_Write_Successfully';
let eventName20_4 : string = 'Temp_UriPermissionTest_0200_Write_Failed';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_WRITE).then((file) => {
console.info('write file fd: ' + file.fd);
commonEvent.publish(eventName20_3, (err) => {
console.log('Hap2MainAbility2' + eventName20_3);
});
}).catch((err) => {
console.info('write open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName20_4, (err) => {
console.log('Hap2MainAbility2' + eventName20_4);
});
});
break;
}
case 21: {
let eventName : string = 'StartDone_Hap2MainAbility2';
commonEvent.publish(eventName, (err) => {
console.log('Hap2MainAbility2' + eventName);
});
break;
}
default:
break;
}
}
onBackground() {
console.log('[Demo] Hap2MainAbility2 onBackground')
}
};
/*
* 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';
export default class Hap2MainAbility3 extends Ability {
onCreate(want, launchParam) {
console.log('[Demo] Hap2MainAbility3 onCreate')
globalThis.abilityWant3 = want;
globalThis.Hap2MainAbility3Context = this.context;
let eventName : string = 'TerminateSelf_Hap2MainAbility3';
let subscribeInfo = {
events: [eventName]
}
function SubscribeCallBackContext(err, data) {
console.log('Subscribe CallBack data:' + JSON.stringify(data));
if (data.event === eventName) {
globalThis.Hap2MainAbility3Context.terminateSelf();
}
}
let subscriber_1;
commonEvent.createSubscriber(subscribeInfo).then(async (data) => {
subscriber_1 = data;
console.debug('====>Create Subscriber====>');
await commonEvent.subscribe(subscriber_1, SubscribeCallBackContext);
});
}
onDestroy() {
console.log('[Demo] Hap2MainAbility3 onDestroy')
let eventName2 : string = 'TerminateDone_Hap2MainAbility3';
commonEvent.publish(eventName2, (err) => {
console.log('Hap2MainAbility3' + eventName2);
});
}
onNewWant(want, launchParams) {
globalThis.abilityWant3 = want;
}
onWindowStageCreate(windowStage) {
console.log('[Demo] Hap2MainAbility3 onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/Hap2MainAbility3_pages', null)
}
onWindowStageDestroy() {
console.log('[Demo] Hap2MainAbility3 onWindowStageDestroy')
}
onForeground() {
console.log('[Demo] Hap2MainAbility3 onForeground ' + globalThis.abilityWant3.parameters['number'])
let uri : string = globalThis.abilityWant3.uri;
if (uri == null) {
console.log('[Demo] Hap2MainAbility3 uri is invalid');
return;
}
switch (globalThis.abilityWant3.parameters['number']) {
case 30: {
console.log('[Demo] Hap2MainAbility3 enter 30');
let eventName30_1 : string = 'Temp_UriPermissionTest_0400_Read_Successfully';
let eventName30_2 : string = 'Temp_UriPermissionTest_0400_Read_Failed';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_ONLY).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName30_1, (err) => {
console.log('Hap2MainAbility3' + eventName30_1);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName30_2, (err) => {
console.log('Hap2MainAbility3' + eventName30_2);
});
});
let eventName30_3 : string = 'Temp_UriPermissionTest_0400_Write_Successfully';
let eventName30_4 : string = 'Temp_UriPermissionTest_0400_Write_Failed';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_WRITE).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName30_3, (err) => {
console.log('Hap2MainAbility3' + eventName30_3);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName30_4, (err) => {
console.log('Hap2MainAbility3' + eventName30_4);
});
});
this.context.terminateSelf();
break;
}
case 31: {
console.log('[Demo] Hap2MainAbility3 enter 31');
let eventName31_1 : string = 'Temp_UriPermissionTest_0400_Read_Successfully_';
let eventName31_2 : string = 'Temp_UriPermissionTest_0400_Read_Failed_';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_ONLY).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName31_1, (err) => {
console.log('Hap2MainAbility3' + eventName31_1);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName31_2, (err) => {
console.log('Hap2MainAbility3' + eventName31_2);
});
});
break;
}
default:
console.log('[Demo] Hap2MainAbility3 enter default.');
break;
}
}
onBackground() {
console.log('[Demo] Hap2MainAbility3 onBackground')
}
};
/*
* 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';
export default class Hap2MainAbility4 extends Ability {
onCreate(want, launchParam) {
console.log('[Demo] Hap2MainAbility4 onCreate')
}
onDestroy() {
console.log('[Demo] Hap2MainAbility4 onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('[Demo] Hap2MainAbility4 onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/Hap2MainAbility4_pages', null)
}
onWindowStageDestroy() {
console.log('[Demo] Hap2MainAbility4 onWindowStageDestroy')
}
onForeground() {
console.log('[Demo] Hap2MainAbility4 onForeground')
let uri : string = globalThis.abilityWant3.uri;
if (uri == null) {
console.log('[Demo] Hap2MainAbility1 uri is invalid');
return;
}
let eventName1 : string = 'Temp_UriPermissionTest_0300_Read_Successfully';
let eventName2 : string = 'Temp_UriPermissionTest_0300_Read_Failed';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_ONLY).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName1, (err) => {
console.log('Hap2MainAbility4' + eventName1);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName2, (err) => {
console.log('Hap2MainAbility4' + eventName2);
});
});
let eventName3 : string = 'Temp_UriPermissionTest_0300_Write_Successfully';
let eventName4 : string = 'Temp_UriPermissionTest_0300_Write_Failed';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_WRITE).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName3, (err) => {
console.log('Hap2MainAbility4' + eventName3);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName4, (err) => {
console.log('Hap2MainAbility4' + eventName4);
});
});
let eventName5 : string = 'TerminateDone_Hap2MainAbility3';
let subscribeInfo = {
events: [eventName5]
}
let eventName6 : string = 'Temp_UriPermissionTest_0300_Read_Successfully_';
let eventName7 : string = 'Temp_UriPermissionTest_0300_Read_Failed_';
function SubscribeCallBackContext(err, data) {
console.log(' Subscribe CallBack data:' + JSON.stringify(data));
if (data.event === eventName5) {
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_ONLY).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName6, (err) => {
console.log('Hap2MainAbility4' + eventName6);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName7, (err) => {
console.log('Hap2MainAbility4' + eventName7);
});
});
}
}
let subscriber__1;
commonEvent.createSubscriber(subscribeInfo).then(async (data) => {
subscriber__1 = data;
console.debug('====>Create Subscriber====>');
await commonEvent.subscribe(subscriber__1, SubscribeCallBackContext);
});
let eventName : string = 'TerminateSelf_Hap2MainAbility3';
commonEvent.publish(eventName, (err) => {
console.log('Hap2MainAbility4' + eventName);
});
}
onBackground() {
console.log('[Demo] Hap2MainAbility4 onBackground')
}
};
/*
* 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 Hap2MainAbility1_pages {
@State message: string = 'Hap2MainAbility1'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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 Hap2MainAbility2_pages {
@State message: string = 'Hap2MainAbility2'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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 Hap2MainAbility3_pages {
@State message: string = 'Hap2MainAbility3'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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 Hap2MainAbility4_pages {
@State message: string = 'Hap2MainAbility4'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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 ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want) {
console.info('ServiceAbility onCreate');
}
onDestroy() {
console.info('ServiceAbility onDestroy');
}
};
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:hap2_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "Hap2MainAbility1",
"srcEntrance": "./ets/Hap2MainAbility1/Hap2MainAbility1.ts",
"description": "$string:Hap2MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility1_label",
"visible": true,
"orientation": "portrait"
},
{
"name": "Hap2MainAbility2",
"srcEntrance": "./ets/Hap2MainAbility2/Hap2MainAbility2.ts",
"description": "$string:Hap2MainAbility2_desc",
"icon": "$media:icon",
"visible": true,
"label": "$string:Hap2MainAbility2_label"
},
{
"name": "Hap2MainAbility3",
"srcEntrance": "./ets/Hap2MainAbility3/Hap2MainAbility3.ts",
"description": "$string:Hap2MainAbility3_desc",
"icon": "$media:icon",
"visible": true,
"label": "$string:Hap2MainAbility3_label",
"skills": [
{
"entities": [
"entity.system.uripermissiontest"
],
"actions": [
"action.system.uripermissiontest"
],
"uris": [
{
"scheme":"file"
}
]
}
]
},
{
"name": "Hap2MainAbility4",
"srcEntrance": "./ets/Hap2MainAbility4/Hap2MainAbility4.ts",
"description": "$string:Hap2MainAbility4_desc",
"icon": "$media:icon",
"visible": true,
"label": "$string:Hap2MainAbility4_label",
"launchType": "singleton"
}
],
"extensionAbilities": [
{
"name": "ServiceAbility",
"srcEntrance": "./ets/serviceability/ServiceAbility.ts",
"label": "$string:ServiceAbility_label",
"visible": true,
"description": "$string:ServiceAbility_desc",
"type": "service"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "hap2_desc",
"value": "description"
},
{
"name": "Hap2MainAbility1_desc",
"value": "description"
},
{
"name": "Hap2MainAbility1_label",
"value": "label"
},
{
"name": "Hap2MainAbility2_desc",
"value": "description"
},
{
"name": "Hap2MainAbility2_label",
"value": "label"
},
{
"name": "Hap2MainAbility3_desc",
"value": "description"
},
{
"name": "Hap2MainAbility3_label",
"value": "label"
},
{
"name": "Hap2MainAbility4_desc",
"value": "description"
},
{
"name": "Hap2MainAbility4_label",
"value": "label"
},
{
"name": "ServiceAbility_desc",
"value": "service_description"
},
{
"name": "ServiceAbility_label",
"value": "service_label"
}
]
}
{
"src": [
"pages/Hap2MainAbility1_pages",
"pages/Hap2MainAbility2_pages",
"pages/Hap2MainAbility3_pages",
"pages/Hap2MainAbility4_pages"
]
}
\ No newline at end of file
/*
* 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';
export default class Hap4MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log('[Demo] Hap4MainAbility1 onCreate')
}
onDestroy() {
console.log('[Demo] Hap4MainAbility1 onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('[Demo] Hap4MainAbility1 onWindowStageCreate')
windowStage.setUIContent(this.context, 'pages/Hap4MainAbility1_pages', null)
}
onWindowStageDestroy() {
console.log('[Demo] Hap4MainAbility1 onWindowStageDestroy')
}
onForeground() {
console.log('[Demo] Hap4MainAbility1 onForeground')
let uri : string = globalThis.abilityWant1.uri;
if (uri == null || uri == undefined) {
console.log('[Demo] Hap2MainAbility1 uri is invalid');
return;
}
let eventName1 : string = 'Temp_UriPermissionTest_0500_Read_Successfully';
let eventName2 : string = 'Temp_UriPermissionTest_0500_Read_Failed';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_ONLY).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName1, (err) => {
console.log('Hap2MainAbility2' + eventName1);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName2, (err) => {
console.log('Hap2MainAbility2' + eventName2);
});
});
let eventName3 : string = 'Temp_UriPermissionTest_0500_Write_Successfully';
let eventName4 : string = 'Temp_UriPermissionTest_0500_Write_Failed';
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_WRITE).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName3, (err) => {
console.log('Hap2MainAbility2' + eventName3);
});
}).catch((err) => {
console.info('open file failed with error message: ' + err.message + ', error code: ' + err.code);
commonEvent.publish(eventName4, (err) => {
console.log('Hap2MainAbility2' + eventName4);
});
});
}
onBackground() {
console.log('[Demo] Hap4MainAbility1 onBackground')
}
};
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hap4MainAbility1'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "hap4",
"type": "feature",
"description": "$string:hap4_desc",
"mainElement": "Hap4MainAbility1",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "Hap4MainAbility1",
"srcEntrance": "./ets/Hap4MainAbility1/Hap4MainAbility1.ts",
"description": "$string:Hap4MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:Hap4MainAbility1_label",
"visible": true,
"orientation": "portrait"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "hap4_desc",
"value": "description"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "Hap4MainAbility1_desc",
"value": "description"
},
{
"name": "Hap4MainAbility1_label",
"value": "label"
}
]
}
{
"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
}
}
}
{
"string":[
{
"name":"app_name",
"value":"UriPermissionAssistanthap2Test"
}
]
}
\ No newline at end of file
# 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"
}
/*
* 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'
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===")
}
function SubscribeCallBackContext(err, data) {
console.log('Hap3MainAbility1 Subscribe CallBack data:' + JSON.stringify(data));
if (data.event === eventName) {
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')
}
};
/*
* 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
{
"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
{
"string": [
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "hap3_desc",
"value": "description"
},
{
"name": "Hap3MainAbility1_desc",
"value": "description"
},
{
"name": "Hap3MainAbility1_label",
"value": "label"
}
]
}
# 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("ActsFaSupportUri") {
hap_profile = "entry/src/main/config.json"
hap_name = "ActsFaSupportUri"
testonly = true
deps = [
":fasupporturi_resources",
":fasupporturi_ts_assets",
]
certificate_profile = "signature/openharmony_sx.p7b"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_js_assets("fasupporturi_ts_assets") {
source_dir = "entry/src/main/ets"
hap_profile = "entry/src/main/config.json"
ets2abc = true
}
ohos_resources("fasupporturi_resources") {
sources = [ "entry/src/main/resources" ]
hap_profile = "entry/src/main/config.json"
}
{
"app": {
"vendor": "example",
"bundleName": "com.example.faapplication",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 8,
"target": 9
}
},
"deviceConfig": {},
"module": {
"mainAbility": ".MainAbility",
"deviceType": [
"default",
"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": "singleton"
}
],
"distro": {
"moduleType": "entry",
"installationFree": false,
"deliveryWithInstall": true,
"moduleName": "entry"
},
"package": "com.example.faapplication",
"srcPath": "",
"name": ".entry",
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureAbility';
import fileUri from '@ohos.file.fileuri';
import fs from '@ohos.file.fs';
import wantConstant from '@ohos.ability.wantConstant';
let printLog1 : string = '[demo] FaMainAbility'
export default {
onCreate() {
console.info(printLog1 + 'onCreate');
let context = featureAbility.getContext()
console.info(printLog1 + ' onCreate get context');
context.getFilesDir().then((path) => {
console.info(printLog1 + ' onCreate get path');
let filePath : string = path + "/test_A.txt";
fs.open(filePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE, (err, file) => {
if (err) {
console.info(printLog1 + " mkdir failed with error message: " + err.message + ", error code: " + err.code);
} else {
console.info(printLog1 + " file created, fd: " + file.fd);
let uri : string = fileUri.getUriFromPath(filePath);
console.info(printLog1 + ' onCreate uri: ' + JSON.stringify(uri));
let want = {
flags : wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION,
bundleName : "com.acts.authorizeduriapplication",
abilityName : "Hap2MainAbility1",
uri : uri,
parameters : {
number : 19
}
}
let param = {
want: want
}
featureAbility.startAbility(param).then(() => {
console.log('startAbility succeed');
}).catch((error) => {
console.log('startAbility failed, error.code: ' + JSON.stringify(error.code) + ' error.message: ' + JSON.stringify(error.message));
});
}
});
})
},
onDestroy() {
console.info(printLog1 + 'onDestroy');
},
onActive() {
console.info(printLog1 + 'onActive');
},
onInactive() {
console.info(printLog1 + 'onInactive');
},
onShow() {
console.info(printLog1 + 'onShow');
},
onHide() {
console.info(printLog1 + 'onHide');
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hello World Test Fa'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"string": [
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "FaSupplement"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.stageautosign",
"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
}
}
}
{
"string":[
{
"name":"app_name",
"value":"UriPermissionTest"
}
]
}
\ No newline at end of file
# 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_js_hap_suite("ActsTempUriPermissionHapTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actstempuripermissionhaptest_js_assets",
":actstempuripermissionhaptest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsTempUriPermissionHapTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actstempuripermissionhaptest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actstempuripermissionhaptest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actstempuripermissionhaptest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actstempuripermissionhaptest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "180000",
"bundle-name": "com.example.stageautosign",
"module-name": "phone",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsTempUriPermissionHapTest.hap",
"ActsAssistantHap.hap",
"ActsAssistantHap2.hap",
"ActsAssistantHap4.hap",
"ActsFaSupportUri.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602",
"uinput -T -d 300 600 -m 300 600 300 100 -u 300 100"
]
}
]
}
/*
* 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'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log('[Demo] MainAbility onCreate')
}
onDestroy() {
console.log('[Demo] MainAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('[Demo] MainAbility onWindowStageCreate')
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, 'MainAbility/pages/MainAbility_pages', null)
}
onWindowStageDestroy() {
console.log('[Demo] MainAbility onWindowStageDestroy')
}
onForeground() {
console.log('[Demo] MainAbility onForeground')
}
onBackground() {
console.log('[Demo] MainAbility onBackground')
}
};
/*
* 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 router from '@ohos.router';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
@State message: string = 'MainAbility'
aboutToAppear() {
console.info("start run testcase!!!!")
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
console.log('TestAbility onCreate')
}
onDestroy() {
console.log('TestAbility onDestroy')
}
onWindowStageCreate(windowStage) {
console.log('TestAbility onWindowStageCreate')
windowStage.loadContent("TestAbility/pages/index", (err, data) => {
if (err.code) {
console.error('Failed to load the content. Cause:' + JSON.stringify(err));
return;
}
console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data))
});
globalThis.abilityContext = this.context;
}
onWindowStageDestroy() {
console.log('TestAbility onWindowStageDestroy')
}
onForeground() {
console.log('TestAbility onForeground')
}
onBackground() {
console.log('TestAbility onBackground')
}
};
\ No newline at end of file
/*
* 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 router from '@ohos.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
let abilityDelegator = undefined
let 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',
'-s dryRun'
])
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()
let testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
let cmd = 'aa start -d 0 -a com.example.stageautosign.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
let debug = abilityDelegatorArguments.parameters['-D']
if (debug === 'true')
{
cmd += ' -D'
}
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 end')
}
};
\ No newline at end of file
/*
* 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 uriPermissionTest from './UriPermissionTest'
export default function List() {
uriPermissionTest()
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.stageautosign.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait"
}
],
"requestPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_RUNNING_INFO",
"reason": "need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND",
"reason":"need use ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsLifecycleMultihapTest"
},
{
"name": "description_application",
"value": "demo for test"
}
]
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册