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

!8570 支持跨UserID后台call调用相关st测试

Merge pull request !8570 from xinking129/master
......@@ -27,6 +27,7 @@ group("ability_runtime") {
"actsabilityusertest:ActsAbilityuserTest",
"actscalldataabilitytest:ActsCallDataAbilityTest",
"actscalltest:actscalltest",
"actscrosscall:actscrosscall",
"actsdataabilityaccessdatasharetest:dataabilityaccessdatashare",
"actsfwkdataaccessortest:dataability",
"actsqueryfunctiontest:actsqueryfunctiontest",
......
# 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("actscrosscall") {
testonly = true
if (is_standard_system) {
deps = [
"actscrosscalleerely:ActsCrossCalleeRely",
"actscrosscallernopermissionrely:ActsCrossCallerNoPermissionRely",
"actscrosscallernormalrely:ActsCallerNormalRely",
"actscrosscallerrely:ActsCrossCallerRely",
"actscrosscalltest:ActsCrossCallTest",
]
}
}
{
"app": {
"bundleName": "com.acts.calleeabilityrely",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "ActsCalleeAbilityRely"
}
]
}
# 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("ActsCrossCalleeRely") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actscrosscalleerely_js_assets",
":actscrosscalleerely_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCrossCalleeRely"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actscrosscalleerely_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actscrosscalleerely_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actscrosscalleerely_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actscrosscalleerely_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 hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
class MyParcelAble {
num: number = 0;
str: String = '';
result: boolean = false;
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
MyParcelAble(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeBoolean(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readBoolean();
return true;
}
}
function callWithResult(data) {
console.log('====>Callee callWithResult called')
let recvSequence = new MyParcelAble(0, '', false);
data.readParcelable(recvSequence);
let result = true;
let str = recvSequence.str + ' processed';
recvSequence.MyParcelAble(recvSequence.num, str, result);
return recvSequence;
}
export default class EntryAbility extends Ability {
onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
this.callee.on('call', callWithResult);
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability 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 = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "calleeRely"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "calleeRely"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "calleeRely"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.acts.actscallpermissionrely",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "ActsCallNoPermissionAbility"
}
]
}
# 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("ActsCrossCallerNoPermissionRely") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actscrosscallernopermissionrely_js_assets",
":actscrosscallernopermissionrely_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCrossCallerNoPermissionRely"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actscrosscallernopermissionrely_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actscrosscallernopermissionrely_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actscrosscallernopermissionrely_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actscrosscallernopermissionrely_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 hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
import commonEvent from '@ohos.commonEventManager'
var message;
var commonEventData = {
parameters:{
message:message,
}
}
var actionStr;
var accountId;
export default class EntryAbility extends Ability {
onCreate(want, launchParam) {
actionStr = want.parameters.action;
accountId = want.parameters.accountId;
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
globalThis.terminate = () => {
setTimeout(() => {
this.context.terminateSelf().then(() => {
console.info("====>EntryAbility terminateSelf end");
}).catch((err) => {
console.info("====>EntryAbility terminateSelf err:" + JSON.stringify(err));
});
}, 50)
};
if (actionStr === 'Acts_CrossUserCall_0700') {
this.context.startAbilityByCallWithAccount({
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
}, accountId).then((data) => {
console.info('====>' + actionStr + ' startAbilityByCall data:' + JSON.stringify(data));
}).catch((err) => {
console.info('====>' + actionStr + ' startAbilityByCall err:' + JSON.stringify(err));
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability 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 = 'Hello World'
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 commonEvent from '@ohos.commonEventManager'
import rpc from '@ohos.rpc';
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
var actionStr;
var accountId;
var message;
var commonEventData = {
parameters:{
message:message,
}
}
let remoteOBJ = new StubTest("test");
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want){
actionStr = want.parameters.action;
accountId = want.parameters.accountId;
console.info('ServiceAbility onCreate want:' + JSON.stringify(want));
globalThis.terminate = () => {
setTimeout(() => {
this.context.terminateSelf().then(() => {
console.info("====>ServiceAbility terminateSelf end");
}).catch((err) => {
console.info("====>ServiceAbility terminateSelf err:" + JSON.stringify(err));
});
}, 50)
};
if (actionStr === 'Acts_CrossUserCall_0800') {
this.context.startAbilityByCallWithAccount({
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
}, accountId).then((data) => {
console.info('====>' + actionStr + ' startAbilityByCall data:' + JSON.stringify(data));
}).catch((err) => {
console.info('====>' + actionStr + ' startAbilityByCall err:' + JSON.stringify(err));
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
}
onDestroy() {
console.info('ServiceAbility onDestroy');
}
onRequest(want, startId) {
console.info('ServiceAbility onRequest');
}
onConnect(want) {
console.info('ServiceAbility onConnect');
return remoteOBJ;
}
onDisconnect(want) {
console.info('ServiceAbility onDisconnect');
}
onReconnect(want) {
console.info('ServiceAbility onReconnect');
}
onConfigurationUpdate(newConfig) {
console.info('ServiceAbility onConfigurationUpdate');
}
onDump(params) {
console.info('ServiceAbility onDump');
return params;
}
};
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "ServiceAbility",
"srcEntrance": "./ets/serviceability/ServiceAbility.ts",
"label": "$string:ServiceAbility_label",
"description": "$string:ServiceAbility_desc",
"type": "service",
"visible": true
}
],"requestPermissions": [
{
"name":"ohos.permission.ABILITY_BACKGROUND_COMMUNICATION"
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "noPermissionRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "noPermissionRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "noPermissionRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.acts.actscallnormalrely",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
{
"string": [
{
"name": "app_name",
"value": "ActsCallNormalAbilityTest"
}
]
}
# 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("ActsCallerNormalRely") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actscallernormalrely_js_assets",
":actscallernormalrely_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCallerNormalRely"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actscallernormalrely_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actscallernormalrely_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actscallernormalrely_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actscallernormalrely_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 hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
import commonEvent from '@ohos.commonEventManager'
var message;
var commonEventData = {
parameters:{
message:message,
}
}
var actionStr;
var accountId;
export default class EntryAbility extends Ability {
onCreate(want, launchParam) {
actionStr = want.parameters.action;
accountId = want.parameters.accountId;
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
globalThis.terminate = () => {
setTimeout(() => {
this.context.terminateSelf().then(() => {
console.info("====>EntryAbility terminateSelf end");
}).catch((err) => {
console.info("====>EntryAbility terminateSelf err:" + JSON.stringify(err));
});
}, 50)
};
if (actionStr === 'Acts_CrossUserCall_0500') {
this.context.startAbilityByCallWithAccount({
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
}, accountId).then((data) => {
console.info('====>' + actionStr + ' startAbilityByCall data:' + JSON.stringify(data));
}).catch((err) => {
console.info('====>' + actionStr + ' startAbilityByCall err:' + JSON.stringify(err));
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability 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 = 'Hello World'
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 commonEvent from '@ohos.commonEventManager'
import rpc from '@ohos.rpc';
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
var actionStr;
var accountId;
var message;
var commonEventData = {
parameters:{
message:message,
}
}
let remoteOBJ = new StubTest("test");
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want){
actionStr = want.parameters.action;
accountId = want.parameters.accountId;
console.info('ServiceAbility onCreate want:' + JSON.stringify(want));
globalThis.terminate = () => {
setTimeout(() => {
this.context.terminateSelf().then(() => {
console.info("====>ServiceAbility terminateSelf end");
}).catch((err) => {
console.info("====>ServiceAbility terminateSelf err:" + JSON.stringify(err));
});
}, 50)
};
if (actionStr === 'Acts_CrossUserCall_0600') {
this.context.startAbilityByCallWithAccount({
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
}, accountId).then((data) => {
console.info('====>' + actionStr + ' startAbilityByCall data:' + JSON.stringify(data));
}).catch((err) => {
console.info('====>' + actionStr + ' startAbilityByCall err:' + JSON.stringify(err));
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
}
onDestroy() {
console.info('ServiceAbility onDestroy');
}
onRequest(want, startId) {
console.info('ServiceAbility onRequest');
}
onConnect(want) {
console.info('ServiceAbility onConnect');
return remoteOBJ;
}
onDisconnect(want) {
console.info('ServiceAbility onDisconnect');
}
onReconnect(want) {
console.info('ServiceAbility onReconnect');
}
onConfigurationUpdate(newConfig) {
console.info('ServiceAbility onConfigurationUpdate');
}
onDump(params) {
console.info('ServiceAbility onDump');
return params;
}
};
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "ServiceAbility",
"srcEntrance": "./ets/serviceability/ServiceAbility.ts",
"label": "$string:ServiceAbility_label",
"description": "$string:ServiceAbility_desc",
"type": "service",
"visible": true
}
],
"requestPermissions": [
{
"name":"ohos.permission.ABILITY_BACKGROUND_COMMUNICATION"
},
{
"name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "normalRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "normalRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "normalRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.acts.actscallability",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
# 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("ActsCrossCallerRely") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actscrosscallerrely_js_assets",
":actscrosscallerrely_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCrossCallerRely"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actscrosscallerrely_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actscrosscallerrely_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actscrosscallerrely_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actscrosscallerrely_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 hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import Window from '@ohos.window'
import commonEvent from '@ohos.commonEventManager'
class MyParcelAble {
num: number = 0;
str: String = '';
result: boolean = false;
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
MyParcelAble(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeBoolean(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readBoolean();
return true;
}
}
var message;
var commonEventData = {
parameters:{
message:message,
}
}
var actionStr;
var accountId;
export default class EntryAbility extends Ability {
onCreate(want, launchParam) {
actionStr = want.parameters.action;
accountId = want.parameters.accountId;
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
globalThis.terminate = () => {
setTimeout(() => {
this.context.terminateSelf().then(() => {
console.info("====>EntryAbility terminateSelf end");
}).catch((err) => {
console.info("====>EntryAbility terminateSelf err:" + JSON.stringify(err));
});
}, 50)
};
if (actionStr === 'Acts_CrossUserCall_0100' || actionStr === 'Acts_CrossUserCall_0300') {
this.context.startAbilityByCallWithAccount({
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
}, accountId).then((data) => {
console.info('====>' + actionStr + ' startAbilityByCall data:' + JSON.stringify(data));
commonEventData.parameters.message = data;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' publish err:' + JSON.stringify(err));
globalThis.terminate();
})
}).catch((err) => {
console.info('====>' + actionStr + ' startAbilityByCall err:' + JSON.stringify(err));
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
if (actionStr === 'Acts_CrossUserCall_2900') {
var caller;
function releaseCallback(data) {
console.info('====>' + actionStr + ' releaseCallBack:' + data);
commonEventData.parameters.message = data;
commonEvent.publish('ACTS_CROSS_RELEASE_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' onRelease event publish err:' + JSON.stringify(err));
})
}
this.context.startAbilityByCallWithAccount({
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
}, accountId).then((data) => {
caller = data;
caller.onRelease(releaseCallback);
let param = new MyParcelAble(2900, 'Acts_CrossUserCall_2900', false);
caller.callWithResult('call', param).then((data) => {
var result = new MyParcelAble(0, '', false);
data.readParcelable(result);
console.info('====>' + actionStr + ' callWithResult result:' + JSON.stringify(result));
commonEventData.parameters.message = result;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' call event publish err:' + JSON.stringify(err));
globalThis.terminate();
})
caller.release();
})
}).catch((err) => {
console.info('====>' + actionStr + ' startAbilityByCall err:' + JSON.stringify(err));
})
}
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
// Main window is created, set main page for this ability
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
}
onForeground() {
// Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground');
}
onBackground() {
// Ability has back to background
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability 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 = 'Hello World'
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 commonEvent from '@ohos.commonEventManager'
import rpc from '@ohos.rpc';
import ServiceExtensionAbility from '@ohos.app.ability.ServiceExtensionAbility'
class MyParcelAble {
num: number = 0;
str: String = '';
result: boolean = false;
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
MyParcelAble(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeBoolean(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readBoolean();
return true;
}
}
class StubTest extends rpc.RemoteObject {
constructor(des) {
super(des)
}
onRemoteRequest(code, data, reply, option) {
console.info('ServiceAbility onRemoteRequest');
if (code === 1) {
let op1 = data.readInt();
let op2 = data.readInt();
reply.writeInt(op1 + op2);
console.info('ServiceAbility op1:' + op1 + ' op2:' + op2);
}
return true;
}
}
var actionStr;
var accountId;
var message;
var commonEventData = {
parameters:{
message:message,
}
}
let remoteOBJ = new StubTest("test");
export default class ServiceAbility extends ServiceExtensionAbility {
onCreate(want){
actionStr = want.parameters.action;
accountId = want.parameters.accountId;
console.info('ServiceAbility onCreate want:' + JSON.stringify(want));
globalThis.terminate = () => {
setTimeout(() => {
this.context.terminateSelf().then(() => {
console.info("====>ServiceAbility terminateSelf end");
}).catch((err) => {
console.info("====>ServiceAbility terminateSelf err:" + JSON.stringify(err));
});
}, 50)
};
globalThis.Acts_CrossUserCall_1000 = () => {
this.context.startAbilityByCallWithAccount(null, -1).then((caller) => {
console.info("====>Acts_CrossUserCall_1000 caller:" + caller)
}).catch((err) => {
console.info("====>Acts_CrossUserCall_1000 err: " + JSON.stringify(err))
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>Acts_CrossUserCall_1000 publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
globalThis.Acts_CrossUserCall_1200 = () => {
this.context.startAbilityByCallWithAccount(undefined, -1).then((caller) => {
console.info("====>Acts_CrossUserCall_1200 caller: " + caller)
}).catch((err) => {
console.info("====>Acts_CrossUserCall_1200 err: " + JSON.stringify(err))
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>Acts_CrossUserCall_1200 publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
globalThis.Acts_CrossUserCall_1400 = () => {
let want = {
bundleName: "xxxx.xxxx.xxxx",
abilityName: "xxxx",
moduleName: "xxxxxx"
}
this.context.startAbilityByCallWithAccount(want, 100).then((caller) => {
console.info("====>Acts_CrossUserCall_1400 caller: " + caller)
}).catch((err) => {
console.info("====>Acts_CrossUserCall_1400 err: " + JSON.stringify(err))
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>Acts_CrossUserCall_1400 publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
globalThis.Acts_CrossUserCall_1600 = () => {
let want = {
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
moduleName: "entry"
}
this.context.startAbilityByCallWithAccount(want, null).then((caller) => {
console.info("====>Acts_CrossUserCall_1600 caller " + JSON.stringify(caller))
}).catch((err) => {
console.info("====>Acts_CrossUserCall_1600 err: " + JSON.stringify(err))
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>Acts_CrossUserCall_1600 publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
globalThis.Acts_CrossUserCall_1800 = () => {
let want = {
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
moduleName: "entry"
}
this.context.startAbilityByCallWithAccount(want, undefined).then((caller) => {
console.info("====>Acts_CrossUserCall_1800 caller: " + caller)
}).catch((err) => {
console.info("====>Acts_CrossUserCall_1800 err: " + JSON.stringify(err))
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>Acts_CrossUserCall_1800 publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
globalThis.Acts_CrossUserCall_2000 = () => {
let want = {
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
moduleName: "entry"
}
this.context.startAbilityByCallWithAccount(want, 9527).then((caller) => {
console.info("====>Acts_CrossUserCall_2000 caller: " + caller)
}).catch((err) => {
console.info("====>Acts_CrossUserCall_2000 err: " + JSON.stringify(err));
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>Acts_CrossUserCall_2000 publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
if (actionStr == 'Acts_CrossUserCall_0200' || actionStr == 'Acts_CrossUserCall_0400') {
this.context.startAbilityByCallWithAccount({
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
}, accountId).then((data) => {
console.info('====>' + actionStr + ' startAbilityByCall data:' + JSON.stringify(data));
commonEventData.parameters.message = data;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' publish err:' + JSON.stringify(err));
globalThis.terminate();
})
}).catch((err) => {
console.info('====>' + actionStr + ' startAbilityByCall err:' + JSON.stringify(err));
commonEventData.parameters.message = err;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' publish err:' + JSON.stringify(err));
globalThis.terminate();
})
})
}
if (actionStr == 'Acts_CrossUserCall_3000') {
var caller;
function releaseCallback(data) {
console.info('====>' + actionStr + ' releaseCallBack:' + data);
commonEventData.parameters.message = data;
commonEvent.publish('ACTS_CROSS_RELEASE_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' onRelease event publish err:' + JSON.stringify(err));
})
}
this.context.startAbilityByCallWithAccount({
bundleName: 'com.acts.calleeabilityrely',
abilityName: 'EntryAbility',
}, accountId).then((data) => {
caller = data;
caller.onRelease(releaseCallback);
let param = new MyParcelAble(3000, 'Acts_CrossUserCall_3000', false);
caller.callWithResult('call', param).then((data) => {
var result = new MyParcelAble(0, '', false);
data.readParcelable(result);
console.info('====>' + actionStr + ' callWithResult result:' + JSON.stringify(result));
commonEventData.parameters.message = result;
commonEvent.publish('ACTS_CROSS_CALL_EVENT', commonEventData, (err) => {
console.info('====>' + actionStr + ' call event publish err:' + JSON.stringify(err));
globalThis.terminate();
})
caller.release();
})
}).catch((err) => {
console.info('====>' + actionStr + ' startAbilityByCall err:' + JSON.stringify(err));
})
}
if (want.action === 'Acts_CrossUserCall_1000') {
globalThis.Acts_CrossUserCall_1000()
}else if (want.action === 'Acts_CrossUserCall_1200') {
console.info('====>Acts_CrossUserCall_1200 service');
globalThis.Acts_CrossUserCall_1200()
}else if (want.action === 'Acts_CrossUserCall_1400') {
globalThis.Acts_CrossUserCall_1400()
}else if (want.action === 'Acts_CrossUserCall_1600') {
globalThis.Acts_CrossUserCall_1600()
}else if (want.action === 'Acts_CrossUserCall_1800') {
globalThis.Acts_CrossUserCall_1800()
}else if (want.action === 'Acts_CrossUserCall_2000') {
globalThis.Acts_CrossUserCall_2000()
}
}
onDestroy() {
console.info('ServiceAbility onDestroy');
}
onRequest(want, startId) {
console.info('ServiceAbility onRequest');
}
onConnect(want) {
console.info('ServiceAbility onConnect');
return remoteOBJ;
}
onDisconnect(want) {
console.info('ServiceAbility onDisconnect');
}
onReconnect(want) {
console.info('ServiceAbility onReconnect');
}
onConfigurationUpdate(newConfig) {
console.info('ServiceAbility onConfigurationUpdate');
}
onDump(params) {
console.info('ServiceAbility onDump');
return params;
}
};
\ No newline at end of file
{
"module": {
"name": "entry",
"type": "entry",
"description": "$string:module_desc",
"mainElement": "EntryAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:main_pages",
"abilities": [
{
"name": "EntryAbility",
"srcEntrance": "./ets/entryability/EntryAbility.ts",
"description": "$string:EntryAbility_desc",
"icon": "$media:icon",
"label": "$string:EntryAbility_label",
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
]
}
],
"extensionAbilities": [
{
"name": "ServiceAbility",
"srcEntrance": "./ets/serviceability/ServiceAbility.ts",
"label": "$string:ServiceAbility_label",
"description": "$string:ServiceAbility_desc",
"type": "service"
}
],
"requestPermissions": [
{
"name":"ohos.permission.ABILITY_BACKGROUND_COMMUNICATION"
},
{
"name":"ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS"
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "callerRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "callerRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "模块描述"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "callerRely"
},
{
"name": "ServiceAbility_desc",
"value": "description"
},
{
"name": "ServiceAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.acts.actscallability",
"vendor": "example",
"versionCode": 1000000,
"versionName": "1.0.0",
"icon": "$media:app_icon",
"label": "$string:app_name",
"distributedNotificationEnabled": true,
"keepAlive" : true,
"singleUser": true,
"minAPIVersion": 10,
"targetAPIVersion": 10,
"car": {
"apiCompatibleVersion": 10,
"singleUser": false
}
}
}
# 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("ActsCrossCallTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":actscrosscalltest_js_assets",
":actscrosscalltest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCrossCallTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("actscrosscalltest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actscrosscalltest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actscrosscalltest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actscrosscalltest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for aceceshi Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.acts.actscallability",
"module-name": "entry_test",
"shell-timeout": "600000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"acm create -n user101 -t normal"
],
"teardown-command": [
"acm delete -i 101"
]
},
{
"test-file-name": [
"ActsCrossCalleeRely.hap",
"ActsCrossCallerNoPermissionRely.hap",
"ActsCallerNormalRely.hap",
"ActsCrossCallerRely.hap",
"ActsCrossCallTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup",
"power-shell setmode 602"
]
}
]
}
\ 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 hilog from '@ohos.hilog';
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',
'-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare ');
}
async onRun() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters['-D']
if (debug == 'true')
{
cmd += ' -D'
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd);
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? '');
hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? '');
})
hilog.info(0x0000, 'testTag', '%{public}s', '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 abilityTest from './Ability.test'
export default function testsuite() {
abilityTest()
}
\ 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 hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
import Window from '@ohos.window'
export default class TestAbility extends Ability {
onCreate(want, launchParam) {
globalThis.abilityContext = this.context;
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? '');
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
onDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
}
onWindowStageCreate(windowStage: Window.WindowStage) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
windowStage.loadContent('testability/pages/Index', (err, data) => {
if (err.code) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
return;
}
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s',
JSON.stringify(data) ?? '');
});
}
onWindowStageDestroy() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
}
onForeground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
}
onBackground() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', '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 hilog from '@ohos.hilog';
@Entry
@Component
struct Index {
aboutToAppear() {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', '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
{
"module": {
"name": "entry_test",
"type": "feature",
"description": "$string:module_test_desc",
"mainElement": "TestAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"pages": "$profile:test_pages",
"abilities": [
{
"name": "TestAbility",
"srcEntrance": "./ets/testability/TestAbility.ets",
"description": "$string:TestAbility_desc",
"icon": "$media:icon",
"label": "$string:TestAbility_label",
"visible": true,
"startWindowIcon": "$media:icon",
"startWindowBackground": "$color:start_window_background",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.START_ABILITIES_FROM_BACKGROUND"
}
]
}
}
{
"color": [
{
"name": "start_window_background",
"value": "#FFFFFF"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_test_desc",
"value": "test ability description"
},
{
"name": "TestAbility_desc",
"value": "the test ability"
},
{
"name": "TestAbility_label",
"value": "test label"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册