提交 d0241e07 编写于 作者: C chengxingzhen

xts-startAbilityByCall接口覆盖

Signed-off-by: Nchengxingzhen <chengxingzhen@huawei.com>
上级 ff258d04
......@@ -26,6 +26,7 @@ group("ability_runtime") {
"actsabilitymanageretstest:ActsAbilityManagerEtsTest",
"actsabilityusertest:ActsAbilityuserTest",
"actscalldataabilitytest:ActsCallDataAbilityTest",
"actscalltest:actscalltest",
"actsdataabilityaccessdatasharetest:dataabilityaccessdatashare",
"actsfwkdataaccessortest:dataability",
"actsqueryfunctiontest:actsqueryfunctiontest",
......
......@@ -138,37 +138,5 @@ export default function ActsAmsCallBackFifthScene() {
}
);
})
/*
* @tc.number : Acts_Ams_test_6700
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_6700', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_6700 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_6700 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
}
);
})
})
}
\ No newline at end of file
......@@ -82,36 +82,5 @@ export default function ActsAmsCallBackFirstScene() {
done();
});
})
/*
* @tc.number : Acts_Ams_test_0300
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_0300', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_0300 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_0200 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
});
})
})
}
\ No newline at end of file
......@@ -133,36 +133,5 @@ export default function ActsAmsCallBackFourthScene() {
done();
});
})
/*
* @tc.number : Acts_Ams_test_5100
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_5100', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_5100 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_5100 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
});
})
})
}
\ No newline at end of file
......@@ -99,36 +99,5 @@ export default function ActsAmsCallBackSecondScene() {
done();
});
})
/*
* @tc.number : Acts_Ams_test_1900
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_1900', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_1900 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_1900 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
});
})
})
}
\ No newline at end of file
......@@ -93,36 +93,5 @@ export default function ActsAmsCallBackThirdScene() {
done();
});
})
/*
* @tc.number : Acts_Ams_test_3500
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by CallBack)
*/
it('Acts_Ams_test_3500', 0, async function (done) {
appManager.getProcessRunningInformation(
(error, info) => {
console.info('Acts_Ams_test_3500 getProcessRunningInformation error.code \
' + error.code + ', data length [' + info.length + ']');
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_3500 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
});
})
})
}
\ No newline at end of file
......@@ -149,32 +149,5 @@ export default function ActsAmsTestFifthScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_0200
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_0200', 0, async function (done) {
let info = await appManager.getProcessRunningInformation();
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (let i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_0200 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
......@@ -83,32 +83,5 @@ export default function ActsAmsTestFirstScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_0200
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_0200', 0, async function (done) {
var info = await appManager.getProcessRunningInformation();
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_0200 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
......@@ -152,35 +152,5 @@ export default function ActsAmsTestFourthScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_1800
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_1800', 0, async function (done) {
console.info("sleep begin");
sleep(2000);
console.info("sleep end");
var info = await appManager.getProcessRunningInformation();
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_1800 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
......@@ -105,32 +105,5 @@ export default function ActsAmsTestSecondScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_1800
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_1800', 0, async function (done) {
var info = await appManager.getProcessRunningInformation();
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_1800 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
......@@ -107,34 +107,5 @@ export default function ActsAmsTestThirdScene() {
}
done();
})
/*
* @tc.number : Acts_Ams_test_3400
* @tc.name : getProcessRunningInformation : Get All Running Processes Information
* @tc.desc : Get All Running Processes Information(by Promise)
*/
it('Acts_Ams_test_3400', 0, async function (done) {
var info = await appManager.getProcessRunningInformation();
console.info('Acts_Ams_test_3400 getProcessRunningInformation JSON String: \
' + JSON.stringify(info));
expect(Array.isArray(info)).assertEqual(true);
expect(info.length).assertLarger(0);
for (var i = 0; i < info.length; i++) {
console.info('Acts_Ams_test_3400 getProcessRunningInformation[' + i + "]: \
" + JSON.stringify(info[i]));
expect(typeof (info[i].pid)).assertEqual("number");
expect(info[i].pid).assertLarger(0);
expect(typeof (info[i].processName)).assertEqual("string");
expect(info[i].processName.length).assertLarger(0);
expect(Array.isArray(info[i].bundleNames)).assertEqual(true);
expect(info[i].bundleNames.length).assertLarger(0);
expect(typeof (info[i].uid)).assertEqual("number");
expect(info[i].uid).assertLarger(0);
}
done();
})
})
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("actscalltest") {
testonly = true
if (is_standard_system) {
deps = [
"systemappcalleea:ActsSystemAppCalleeARelyHap",
"systemappcallera:ActsSystemAppCallerARelyHap",
"systemappcallerb:ActsSystemAppCallerBRelyHap",
"systemappcallerc:ActsSystemAppCallerCRelyHap",
"systemcallentrytest:ActsCallTestEntryTest",
"systemcallfeature:ActsCallTestFeatureRelyHap",
"thirdappa:ActsThirdAppARelyHap",
"thirdcalltest:ActsThirdCallTest",
]
}
}
{
"app":{
"bundleName":"com.example.systemappcalleea",
"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":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("ActsSystemAppCalleeARelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemappcalleea_js_assets",
":systemappcalleea_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCalleeARelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemappcalleea_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemappcalleea_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemappcalleea_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemappcalleea_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
var event_case2000 = "call_case2000_test";
var subscribeInfo = {
events: [event_case2000, ],
};
var subscriber;
function test2200ReleaseCallback(data) {
console.log('SystemAppCalleeA MainAbility test2200ReleaseCallback:' + data);
test2200ReleaseFlag = data.toString();
}
var test2200ReleaseFlag = '';
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCalleeA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCalleeA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class MainAbility extends Ability {
test2200(data) {
console.log("SystemAppCalleeA MainAbility test2200");
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let want = {
bundleName: "com.example.systemappcalleea",
abilityName: "com.example.systemappcalleea.SecondAbility",
};
console.log("SystemAppCalleeA MainAbility test2200 before startAbilityByCall");
let resultData = new MySequenceable(0, '', '');
globalThis.abilityContext.startAbilityByCall(want).then((caller) => {
let param = new MySequenceable(recvData.num + 1, recvData.str + "SystemAppCalleeA", '');
caller.onRelease(test2200ReleaseCallback);
caller.callWithResult('test2200', param).then((data2) => {
data2.readSequenceable(resultData);
caller.release();
for (let start=Date.now(); Date.now() - start <= 200;);
resultData.result = test2200ReleaseFlag;
let commonEventData = {
parameters: {
num: resultData.num,
str: resultData.str,
result: resultData.result,
}
};
commonEvent.publish('call_case2200_test_result', commonEventData, (err) => {
console.log('SystemAppCalleeA publish call_case2200_test_result event')
})
});
});
return resultData;
}
subscribeCallBack(err, data) {
console.log('SystemAppCalleeA MainAbility subscribeCallBack data:' + JSON.stringify(data));
switch (data.event) {
case event_case2000:
globalThis.abilityContext.terminateSelf();
break;
default:
console.log('SystemAppCalleeA MainAbility subscribeCallBack event error:' + data.event);
break;
}
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCalleeA MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('test2200', this.test2200);
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
commonEvent.createSubscriber(subscribeInfo).then((data) => {
console.log("SystemAppCalleeA MainAbility createSubscriber");
subscriber = data;
commonEvent.subscribe(subscriber, this.subscribeCallBack);
});
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCalleeA MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCalleeA MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCalleeA MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCalleeA MainAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("SystemAppCalleeA MainAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCalleeA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCalleeA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class SecondAbility extends Ability {
test2200(data) {
console.log("SystemAppCalleeA SecondAbility test2200");
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let result = new MySequenceable(recvData.num + 1, recvData.str + "SystemAppCalleeA", '');
return result;
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCalleeA SecondAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext2 = this.context;
this.callee.on('test2200', this.test2200);
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCalleeA SecondAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCalleeA SecondAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCalleeA SecondAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCalleeA SecondAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("SystemAppCalleeA SecondAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class ThirdAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCalleeA ThirdAbility onCreate")
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
globalThis.abilityWant = want;
globalThis.abilityContext3 = this.context;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCalleeA ThirdAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCalleeA ThirdAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCalleeA ThirdAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCalleeA ThirdAbility onForeground");
}
onBackground() {
// Ability has back to background
console.log("SystemAppCalleeA ThirdAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemappcalleea.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
},
{
"name": "com.example.systemappcalleea.SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton"
},
{
"name": "com.example.systemappcalleea.ThirdAbility",
"srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "standard"
}
]
}
}
{
"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": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemappcallera",
"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":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("ActsSystemAppCallerARelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemappcallera_js_assets",
":systemappcallera_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCallerARelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemappcallera_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemappcallera_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemappcallera_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemappcallera_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
var bundleNameCallee = "com.example.systemcalltest";
var abilityNameCallee = "com.example.systemcalltest.SecondAbility";
var subscriber;
var caller;
var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility";
var event_call = "call.com.example.systemcalltest.SecondAbility";
var event_release = "release.com.example.systemcalltest.SecondAbility";
var subscribeInfo = {
events: [event_getcaller, event_call, event_release, ],
};
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function getCaller(context) {
console.log("SystemAppCallerA MainAbility getCaller");
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
};
context.startAbilityByCall(want).then(data => {
if (typeof data !== "object" || data == null) {
console.log('SystemAppCallerA MainAbility startAbilityByCall fail');
}
caller = data;
});
}
function stressCall() {
console.log('SystemAppCallerA MainAbility stressCall begin');
if (typeof caller !== "object" || caller == null) {
console.log('SystemAppCallerA MainAbility caller error in stressCall');
}
let times = 10;
for (let i = 0; i < times; i++) {
let data = new MySequenceable(i, "SystemAppCallerA", '');
caller.call('stressMethod', data);
}
}
function unsubscribeCallback() {
console.debug("SystemAppCallerA MainAbility unsubscribeCallback");
}
function releaseCallee() {
try {
caller.onRelease(data => {
console.log('SystemAppCallerA MainAbility releaseCallBack:' + data);
});
caller.release();
} catch (e) {
console.log('SystemAppCallerA MainAbility release fail ' + e);
}
commonEvent.unsubscribe(subscriber, unsubscribeCallback);
}
function startNext(context) {
console.log("SystemAppCallerA MainAbility startNext");
let want = {
bundleName: "com.example.systemappcallerb",
abilityName: "com.example.systemappcallerb.MainAbility",
parameters: {case_num: "case5600"},
}
context.startAbility(want,
(err) => {console.log("SystemAppCallerA MainAbility startAbility callback");});
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA MainAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class MainAbility extends Ability {
subscribeCallBack(err, data) {
console.log('SystemAppCallerA MainAbility subscribeCallBack data:' + JSON.stringify(data));
switch (data.event) {
case event_call:
stressCall();
break;
case event_release:
releaseCallee();
break;
default:
console.log('SystemAppCallerA MainAbility subscribeCallBack event error:' + data.event);
break;
}
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerA MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerA MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerA MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerA MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerA MainAbility onForeground");
commonEvent.createSubscriber(subscribeInfo).then((data) => {
console.log("SystemAppCallerA MainAbility createSubscriber");
subscriber = data;
commonEvent.subscribe(subscriber, this.subscribeCallBack);
if (globalThis.abilityWant.parameters["case_num"] == "case5600") {
getCaller(this.context);
startNext(this.context);
}
});
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerA MainAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class SecondAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerA SecondAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerA SecondAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerA SecondAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerA SecondAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerA SecondAbility onForeground");
if ((globalThis.abilityWant.parameters.case_num == "case0700") ||
(globalThis.abilityWant.parameters.case_num == "case0800")) {
console.log("SystemAppCallerA SecondAbility special process in");
var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground";
var commonEventData = {
data: publishData,
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>SystemAppCallerA SecondAbility Call_Finish<======')
})
}
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerA SecondAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA ThirdAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA ThirdAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemAppCallerA ThirdAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
export default class ThirdAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerA ThirdAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
this.callee.on('testCall', testCall);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerA ThirdAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerA ThirdAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerA ThirdAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerA ThirdAbility onForeground");
if ((globalThis.abilityWant.parameters.case_num == "case0700") ||
(globalThis.abilityWant.parameters.case_num == "case0800")) {
var publishData = globalThis.abilityWant.parameters.case_num + "targetForeground";
var commonEventData = {
data: publishData,
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>SystemAppCallerA ThirdAbility Call_Finish<======')
})
}
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerA ThirdAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemappcallera.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
},
{
"name": "com.example.systemappcallera.SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton"
},
{
"name": "com.example.systemappcallera.ThirdAbility",
"srcEntrance": "./ets/ThirdAbility/ThirdAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "standard"
}
]
}
}
{
"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": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemappcallerb",
"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":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("ActsSystemAppCallerBRelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemappcallerb_js_assets",
":systemappcallerb_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCallerBRelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemappcallerb_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemappcallerb_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemappcallerb_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemappcallerb_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
var bundleNameCallee = "com.example.systemcalltest";
var abilityNameCallee = "com.example.systemcalltest.SecondAbility";
var subscriber;
var caller;
var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility";
var event_call = "call.com.example.systemcalltest.SecondAbility";
var event_release = "release.com.example.systemcalltest.SecondAbility";
var subscribeInfo = {
events: [event_getcaller, event_call, event_release, ],
};
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function getCaller(context) {
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
};
context.startAbilityByCall(want).then(data => {
if (typeof data !== "object" || data == null) {
console.log('SystemAppCallerB MainAbility startAbilityByCall fail');
}
caller = data;
});
}
function stressCall() {
console.log('SystemAppCallerB MainAbility stressCall begin');
if (typeof caller !== "object" || caller == null) {
console.log('SystemAppCallerB MainAbility caller error in stressCall');
return;
}
let times = 10;
for (let i = 0; i < times; i++) {
let data = new MySequenceable(i, "SystemAppCallerB", '');
caller.call('stressMethod', data);
}
}
function unsubscribeCallback() {
console.debug("SystemAppCallerB MainAbility unsubscribeCallback");
}
function releaseCallee() {
try {
caller.onRelease(data => {
console.log('SystemAppCallerB MainAbility releaseCallBack:' + data);
});
caller.release();
} catch (e) {
console.log('SystemAppCallerB MainAbility release fail ' + e);
}
commonEvent.unsubscribe(subscriber, unsubscribeCallback);
}
function startNext(context) {
let want = {
bundleName: "com.example.systemappcallerc",
abilityName: "com.example.systemappcallerc.MainAbility",
parameters: {case_num: "case5600"},
}
context.startAbility(want,
(err) => {console.log("SystemAppCallerB MainAbility startAbility callback");});
}
export default class MainAbility extends Ability {
subscribeCallBack(err, data) {
console.log('SystemAppCallerB MainAbility subscribeCallBack data:' + JSON.stringify(data));
switch (data.event) {
case event_call:
stressCall();
break;
case event_release:
releaseCallee();
break;
default:
console.log('SystemAppCallerB MainAbility subscribeCallBack event error:' + data.event);
break;
}
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerB MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerB MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerB MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerB MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerB MainAbility onForeground");
commonEvent.createSubscriber(subscribeInfo).then((data) => {
console.log("SystemAppCallerB MainAbility createSubscriber");
subscriber = data;
commonEvent.subscribe(subscriber, this.subscribeCallBack);
if (globalThis.abilityWant.parameters["case_num"] == "case5600") {
getCaller(this.context);
startNext(this.context);
}
});
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerB MainAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemappcallerb.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
]
}
}
{
"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": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemappcallerc",
"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":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("ActsSystemAppCallerCRelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemappcallerc_js_assets",
":systemappcallerc_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCallerCRelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemappcallerc_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemappcallerc_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemappcallerc_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemappcallerc_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
var bundleNameCallee = "com.example.systemcalltest";
var abilityNameCallee = "com.example.systemcalltest.SecondAbility";
var subscriber;
var caller;
var event_getcaller = "getcaller.com.example.systemcalltest.SecondAbility";
var event_call = "call.com.example.systemcalltest.SecondAbility";
var event_release = "release.com.example.systemcalltest.SecondAbility";
var subscribeInfo = {
events: [event_getcaller, event_call, event_release, ],
};
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function getCaller(context) {
let want = {
bundleName: bundleNameCallee,
abilityName: abilityNameCallee,
};
context.startAbilityByCall(want).then(data => {
if (typeof data !== "object" || data == null) {
console.log('SystemAppCallerC MainAbility startAbilityByCall fail');
}
caller = data;
});
}
function stressCall() {
console.log('SystemAppCallerC MainAbility stressCall begin');
if (typeof caller !== "object" || caller == null) {
console.log('SystemAppCallerC MainAbility caller error in stressCall');
}
let times = 10;
for (let i = 0; i < times; i++) {
let data = new MySequenceable(i, "SystemAppCallerC", '');
caller.call('stressMethod', data);
}
}
function unsubscribeCallback() {
console.debug("SystemAppCallerC MainAbility unsubscribeCallback");
}
function releaseCallee() {
try {
caller.onRelease(data => {
console.log('SystemAppCallerC MainAbility releaseCallBack:' + data);
});
caller.release();
} catch (e) {
console.log('SystemAppCallerC MainAbility release fail ' + e);
}
commonEvent.unsubscribe(subscriber, unsubscribeCallback);
}
function triggerStressEvent() {
let commonEventData = {}
commonEvent.publish(event_call, commonEventData, (err) => {
console.log('SystemAppCallerC publish event')
})
}
export default class MainAbility extends Ability {
subscribeCallBack(err, data) {
console.log('SystemAppCallerC MainAbility subscribeCallBack data:' + JSON.stringify(data));
switch (data.event) {
case event_call:
stressCall();
break;
case event_release:
releaseCallee();
break;
default:
console.log('SystemAppCallerC MainAbility subscribeCallBack event error:' + data.event);
break;
}
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemAppCallerC MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.abilityContext = this.context;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemAppCallerC MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemAppCallerC MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemAppCallerC MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemAppCallerC MainAbility onForeground");
commonEvent.createSubscriber(subscribeInfo).then((data) => {
console.log("SystemAppCallerC MainAbility createSubscriber");
subscriber = data;
commonEvent.subscribe(subscriber, this.subscribeCallBack);
for (let start=Date.now(); Date.now() - start <= 100;);
if (globalThis.abilityWant.parameters["case_num"] == "case5600") {
getCaller(this.context);
triggerStressEvent();
}
});
}
onBackground() {
// Ability has back to background
console.log("SystemAppCallerC MainAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
async function routePage() {
let options = {
uri: 'pages/second'
}
try {
await router.push(options)
} catch (err) {
console.error(`fail callback, code: ${err.code}, msg: ${err.msg}`)
}
}
@Entry
@Component
struct Index {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
routePage()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import router from '@system.router';
@Entry
@Component
struct Second {
private content: string = "Second Page"
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text(`${this.content}`)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('back to index')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
router.back()
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemappcallerc.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
]
}
}
{
"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": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemcalltest",
"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":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("ActsCallTestEntryTest") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemcallentrytest_js_assets",
":systemcallentrytest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCallTestEntryTest"
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemcallentrytest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemcallentrytest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemcallentrytest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemcallentrytest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"bundle-name": "com.example.systemcalltest",
"module-name": "com.example.systemcalltest",
"shell-timeout": "600000",
"testcase-timeout": 70000
},
"kits": [
{
"test-file-name": [
"ActsCallTestEntryTest.hap",
"ActsCallTestFeatureRelyHap.hap",
"ActsSystemAppCallerARelyHap.hap",
"ActsSystemAppCallerBRelyHap.hap",
"ActsSystemAppCallerCRelyHap.hap",
"ActsSystemAppCalleeARelyHap.hap",
"ActsThirdAppARelyHap.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
}
]
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
export default class MainAbility extends Ability {
test2100(data) {
console.log("SystemCallTest MainAbility test2100 begin");
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
return new MySequenceable(recvData.num + 1, recvData.str + "Main", recvData.result);
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest MainAbility onCreate")
globalThis.abilityWant = want;
globalThis.callee = this.callee;
this.callee.on('test2100', this.test2100);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "MainAbility/pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest MainAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../../../test/List.test'
@Entry
@Component
struct Index {
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() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('SystemCallTest SecondAbility)')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
var callerA = "SystemAppCallerA"
var callSeqA= new Array();
var callerB = "SystemAppCallerB"
var callSeqB= new Array();
var callerC = "SystemAppCallerC"
var callSeqC= new Array();
var seq = 0;
function isArrayEqual(a1, a2) {
return a1.length==a2.length && a1.every(function(value,index) { return value === a2[index]});
}
function isArrayEqualWithoutOrder(a1, a2) {
if (a1.length != a2.length) {
return false;
}
for (let ind in a1) {
if (a2.indexOf(a1[ind]) == -1) {
return false;
};
}
return true;
}
var expectStressResult=[0,1,2,3,4,5,6,7,8,9];
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
function testCall(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed';
var commonEventData = {
code: 0,
data: 'calleeCheckCallParam',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCall2(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
var result = recvSequence.str + 'processed2';
var commonEventData = {
code: 0,
data: 'calleeCheckCall2Param',
parameters: {
num: recvSequence.num,
str: recvSequence.str,
result: result
}
}
commonEvent.publish('CallTest', commonEventData, (err) => {
console.log('======>CallTestSysA SecondAbility Call_Finish<======')
})
return recvSequence;
}
function testCallWithResult(data) {
let recvSequence = new MySequenceable(0, '', '');
console.log('======>SystemCallTest SecondAbility on testCall <======')
data.readSequenceable(recvSequence);
let result = recvSequence.str + 'processed';
recvSequence.setMySequence(recvSequence.num, recvSequence.str, result);
return recvSequence;
}
function test2100ReleaseCallback(data) {
console.log('SystemCallTest SecondAbility test2100ReleaseCallback:' + data);
test2100ReleaseFlag = data.toString();
}
var test2100ReleaseFlag = '';
export default class SecondAbility extends Ability {
test2100(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let want = {
bundleName: "com.example.systemcalltest",
abilityName: "com.example.systemcalltest.MainAbility",
};
console.log("SystemCallTest SecondAbility test2100 before startAbilityByCall");
let resultData = new MySequenceable(0, '', '');
globalThis.abilityContext2.startAbilityByCall(want).then((caller) => {
let param = new MySequenceable(recvData.num + 1, recvData.str + "Second", recvData.result);
caller.onRelease(test2100ReleaseCallback);
for (let start=Date.now(); Date.now() - start <= 200;);
caller.callWithResult('test2100', param).then((data2) => {
data2.readSequenceable(resultData);
caller.release();
for (let start=Date.now(); Date.now() - start <= 200;);
resultData.result = test2100ReleaseFlag;
let commonEventData = {
parameters: {
num: resultData.num,
str: resultData.str,
result: resultData.result,
}
};
commonEvent.publish('call_case2100_test_result', commonEventData, (err) => {
console.log('SystemCallTest SecondAbility publish call_case2200_test_result event');
})
});
});
return resultData;
}
testOff(data) {
let recvSequence = new MySequenceable(0, '', '');
data.readSequenceable(recvSequence);
return recvSequence;
}
stressMethod(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
console.log('SystemCallTest SecondAbility stressMethod caller ' + recvData.str);
if (recvData.str == callerA) {
callSeqA.push(recvData.num);
} else if (recvData.str == callerB) {
callSeqB.push(recvData.num);
} else if (recvData.str == callerC) {
callSeqC.push(recvData.num);
}
seq++;
if (seq >= 30) {
console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerA ' + callSeqA);
console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerB ' + callSeqB);
console.log('SystemCallTest SecondAbility stressMethod SystemAppCallerC ' + callSeqC);
let stressResult=isArrayEqualWithoutOrder(callSeqA, expectStressResult);
stressResult=stressResult&&isArrayEqualWithoutOrder(callSeqB, expectStressResult);
stressResult=stressResult&&isArrayEqualWithoutOrder(callSeqC, expectStressResult);
console.log('SystemCallTest SecondAbility stressMethod stressResult ' + stressResult);
let commonEventData = {
data: stressResult.toString(),
};
commonEvent.publish('com.example.systemcalltest.Test5600', commonEventData, (err) => {
console.log('SystemCallTest SecondAbility stress test result event');
});
seq=0;
callSeqA = [];
callSeqB = [];
callSeqC = [];
}
return recvData;
}
loopMethod(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
return new MySequenceable(recvData.num + 1, recvData.str, '');
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest SecondAbility onCreate")
globalThis.abilityWant = want;
globalThis.secondCallee = this.callee;
globalThis.abilityContext2 = this.context;
this.callee.on('test2100', this.test2100);
this.callee.on('testOff', this.testOff);
this.callee.on('stressMethod', this.stressMethod);
this.callee.on('loopMethod', this.loopMethod);
this.callee.on('testCall', testCall);
this.callee.on('testCall2', testCall2);
this.callee.on('testCallWithResult', testCallWithResult);
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest SecondAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest SecondAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/second/second", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest SecondAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest SecondAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest SecondAbility onBackground")
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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.setUIContent(this.context, 'TestAbility/pages/index', null)
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) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s it',
'-s level', '-s testType', '-s size', '-s timeout'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams = `${targetParams} ${key} ${parameters[key]}`
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log("onAbilityCreateCallback");
}
async function addAbilityMonitorCallback(err: any) {
console.info("addAbilityMonitorCallback : " + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info("OpenHarmonyTestRunner OnPrepare ")
}
async onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility'
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a com.example.systemcalltest.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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.ets'
export default function testsuite() {
abilityTest()
}
\ No newline at end of file
{
"module": {
"name": "com.example.systemcalltest",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.systemcalltest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
},
{
"name": "com.example.systemcalltest.SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"launchType": "singleton",
"orientation": "portrait"
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.ABILITY_BACKGROUND_COMMUNICATION",
"reason":"need use ohos.permission.ABILITY_BACKGROUND_COMMUNICATION"
}
]
}
}
{
"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": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"MainAbility/pages/index/index",
"MainAbility/pages/second/second"
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.systemcalltest",
"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":8,
"targetAPIVersion":8,
"car":{
"apiCompatibleVersion":8,
"singleUser":false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"ohosProject"
}
]
}
\ No newline at end of file
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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("ActsCallTestFeatureRelyHap") {
hap_profile = "entry/src/main/module.json"
js_build_mode = "debug"
deps = [
":systemcallfeature_js_assets",
":systemcallfeature_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsCallTestFeatureRelyHap"
testonly = true
subsystem_name = "ability"
part_name = "ability_runtime"
}
ohos_app_scope("systemcallfeature_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("systemcallfeature_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("systemcallfeature_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":systemcallfeature_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.app.ability.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("SystemCallTest Second Hap MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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'
class MySequenceable {
num: number = 0;
str: String = "";
result: String = "";
constructor(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
setMySequence(num, string, result) {
this.num = num;
this.str = string;
this.result = result;
}
marshalling(messageParcel) {
messageParcel.writeInt(this.num);
messageParcel.writeString(this.str);
messageParcel.writeString(this.result);
return true;
}
unmarshalling(messageParcel) {
this.num = messageParcel.readInt();
this.str = messageParcel.readString();
this.result = messageParcel.readString();
return true;
}
}
let callSeq = "";
export default class MainAbility extends Ability {
test2300(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let sendData = new MySequenceable(0, '', '');
if (recvData.num == 2300 && recvData.str == 'case2300') {
sendData.num = 0;
} else {
sendData.num = 1;
}
sendData.str = callSeq;
return sendData;
}
test4600(data) {
let recvData = new MySequenceable(0, '', '');
data.readSequenceable(recvData);
let sendData = new MySequenceable(0, '', '');
if (recvData.num == 4600 && recvData.str == 'case4600') {
sendData.num = 0;
} else {
sendData.num = 1;
}
sendData.str = callSeq;
return sendData;
}
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("SystemCallTest Second Hap MainAbility onCreate")
globalThis.abilityWant = want;
this.callee.on('test2300', this.test2300);
this.callee.on('test4600', this.test4600);
callSeq = callSeq + "onCreate";
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("SystemCallTest Second Hap MainAbility onDestroy")
callSeq = callSeq + "onDestroy";
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("SystemCallTest Second Hap MainAbility onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index", null)
callSeq = callSeq + "onWindowStageCreate";
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("SystemCallTest Second Hap MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("SystemCallTest Second Hap MainAbility onForeground")
callSeq = callSeq + "onForeground";
}
onBackground() {
// Ability has back to background
console.log("SystemCallTest Second Hap MainAbility onBackground")
callSeq = callSeq + "onBackground";
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT 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 {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('second module')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@Entry
@Component
struct Second {
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('SystemCallTest SecondAbility)')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "com.example.second",
"process": "com.example.secondprocess",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"default",
"tablet"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.second.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "singleton",
"skills": [
{
"actions": [
"action.system.home"
],
"entities":[
"entity.system.home"
]
}
]
}
]
}
}
{
"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": "ActsContextTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "serviceability_description",
"value": "my whether"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "app_name",
"value": "Demo"
}
]
}
{
"src": [
"pages/index/index",
"pages/second/second"
]
}
\ No newline at end of file
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册