提交 d833c508 编写于 作者: X xuchenghua09

update

Signed-off-by: Nxuchenghua09 <xuchenghua09@huawei.com>
上级 d02421dc
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
group("abilitymultiinstance") {
testonly = true
if (is_standard_system) {
deps = [
"amsabilitymultiinstanceappa:ActsAmsAbilityMultiinstanceHapARelyHap",
"amsabilitymultiinstanceappb:ActsAmsAbilityMultiinstanceHapBRelyHap",
"amsabilitymultiinstanceappc:ActsAmsAbilityMultiinstanceHapCRelyHap",
"amsabilitymultiinstanceappd:ActsAmsAbilityMultiinstanceHapDRelyHap",
"amsabilitymultiinstanceappe:ActsAmsAbilityMultiinstanceHapERelyHap",
"amsabilitymultiinstancetest:ActsAmsAbilityMultiinstanceTest",
]
}
}
{
"app": {
"bundleName": "com.example.amsabilitymultiinstanceappa",
"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
}
}
}
\ 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("ActsAmsAbilityMultiinstanceHapARelyHap") {
hap_profile = "entry/src/main/module.json"
deps = [
":actsamsabilitymultiinstancehapa_js_assets",
":actsamsabilitymultiinstancehapa_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsAbilityMultiinstanceHapARelyHap"
}
ohos_app_scope("actsamsabilitymultiinstancehapa_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsabilitymultiinstancehapa_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsamsabilitymultiinstancehapa_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsamsabilitymultiinstancehapa_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
const ONACCEPTWANT_KEY_NOTSET_ID = -1;
const ONACCEPTWANT_KEY_UNDEFINED_ID = -2;
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("AbilityMultiInstanceAppA MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
onAcceptWant(want) {
console.log("AbilityMultiInstanceAppA onAcceptWant called want:" + JSON.stringify(want));
if ((want.parameters == undefined) || (want.parameters.startId == undefined)) {
console.log("AbilityMultiInstanceAppA specified param err");
return;
}
var abilityId = want.parameters.startId.toString();
onAcceptWantCalledSeq = "onAcceptWantCalled";
onAcceptWantCalledSeq += "Id";
onAcceptWantCalledSeq += abilityId;
globalThis.onAcceptWantCalledSeq = onAcceptWantCalledSeq;
if (want.parameters.startId == ONACCEPTWANT_KEY_NOTSET_ID) {
return;
} else if (want.parameters.startId == ONACCEPTWANT_KEY_UNDEFINED_ID) {
return undefined;
}
globalThis.abilityWant = want;
console.log("AbilityMultiInstanceAppA set globalThis result :" + globalThis.onAcceptWantCalledSeq);
return abilityId;
}
}
\ 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.application.Ability'
import commonEvent from '@ohos.commonevent'
var callBackSeq = "";
function publishCallBack() {
console.debug("====>Publish CallBack ====>");
}
async function startAbilityProcess(abilityContext, parameters) {
let bundleName = "com.example.amsabilitymultiinstanceappa";
let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility";
let idx = parameters.nextStep;
switch (parameters.step[idx]) {
case "StartA1":
parameters.startId = 1;
break;
case "StartA2":
parameters.startId = 2;
break;
case "StartB":
bundleName = "com.example.amsabilitymultiinstanceappb";
abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility";
break;
case "StartC":
bundleName = "com.example.amsabilitymultiinstanceappc";
abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility";
break;
case "StartDMain1":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 1;
break;
case "StartDMain2":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 2;
break;
case "StartDSec":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility";
break;
case "StartDThd":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility";
break;
case "StartE":
bundleName = "com.example.amsabilitymultiinstanceappe";
abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility";
break;
default:
break;
}
parameters.nextStep = ++idx;
abilityContext.startAbility({
bundleName: bundleName,
abilityName: abilityName,
parameters: parameters
}, (error, data) => {
console.log('AppA startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data))
})
}
async function onShowProcess() {
var abilityWant = globalThis.abilityWant;
var callBackData = "AppA:"
callBackSeq += globalThis.onAcceptWantCalledSeq;
callBackData += callBackSeq;
var commonEventPublishData = {
data: callBackData,
parameters: abilityWant.parameters
};
console.log("AbilityMultiInstanceAppA abilityWant = " + JSON.stringify(abilityWant));
if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) {
commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack);
callBackSeq = "";
globalThis.onAcceptWantCalledSeq = "";
} else {
commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => {
callBackSeq = "";
globalThis.onAcceptWantCalledSeq = "";
startAbilityProcess(globalThis.abilityContext, abilityWant.parameters);
});
}
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceAppA onCreate")
callBackSeq += "onCreate";
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("AbilityMultiInstanceAppA onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("AbilityMultiInstanceAppA onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("AbilityMultiInstanceAppA onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("AbilityMultiInstanceAppA onForeground")
callBackSeq += "onForeground";
onShowProcess();
}
onBackground() {
// Ability has back to background
console.log("AbilityMultiInstanceAppA 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('Ability MultiInstance AppA')
.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": "com.example.amsabilitymultiinstanceappa",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.amsabilitymultiinstanceappa.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "specified",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"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"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.amsabilitymultiinstanceappb",
"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
}
}
}
\ 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("ActsAmsAbilityMultiinstanceHapBRelyHap") {
hap_profile = "entry/src/main/module.json"
deps = [
":actsamsabilitymultiinstancehapb_js_assets",
":actsamsabilitymultiinstancehapb_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsAbilityMultiinstanceHapBRelyHap"
}
ohos_app_scope("actsamsabilitymultiinstancehapb_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsabilitymultiinstancehapb_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsamsabilitymultiinstancehapb_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsamsabilitymultiinstancehapb_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("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.application.Ability'
import commonEvent from '@ohos.commonevent'
var callBackSeq = "";
function publishCallBack() {
console.debug("====>AbilityMultiInstanceAppB Publish CallBack ====>");
}
async function startAbilityProcess(abilityContext, parameters) {
let bundleName = "com.example.amsabilitymultiinstanceappa";
let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility";
let idx = parameters.nextStep;
switch (parameters.step[idx]) {
case "StartA1":
parameters.startId = 1;
break;
case "StartA2":
parameters.startId = 2;
break;
case "StartB":
bundleName = "com.example.amsabilitymultiinstanceappb";
abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility";
break;
case "StartC":
bundleName = "com.example.amsabilitymultiinstanceappc";
abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility";
break;
case "StartDMain1":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 1;
break;
case "StartDMain2":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 2;
break;
case "StartDSec":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility";
break;
case "StartDThd":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility";
break;
case "StartE":
bundleName = "com.example.amsabilitymultiinstanceappe";
abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility";
break;
default:
break;
}
parameters.nextStep = ++idx;
abilityContext.startAbility({
bundleName: bundleName,
abilityName: abilityName,
parameters: parameters
}, (error, data) => {
console.log('AppB startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data))
})
}
async function onShowProcess() {
var abilityWant = globalThis.abilityWant;
var callBackData = "AppB:"
callBackData += callBackSeq;
var commonEventPublishData = {
data: callBackData,
parameters: abilityWant.parameters
};
console.log("AbilityMultiInstanceAppB onShowProcess")
if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) {
commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack);
callBackSeq = "";
} else {
commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => {
callBackSeq = "";
startAbilityProcess(globalThis.abilityContext, abilityWant.parameters);
});
}
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceAppB MainAbility onCreate")
callBackSeq += "onCreate";
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("AbilityMultiInstanceAppB MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("AbilityMultiInstanceAppB MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("AbilityMultiInstanceAppB MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("AbilityMultiInstanceAppB MainAbility onForeground")
callBackSeq += "onForeground";
onShowProcess();
}
onBackground() {
// Ability has back to background
console.log("AbilityMultiInstanceAppB 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('Ability MultiInstance AppB')
.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": "com.example.amsabilitymultiinstanceappb",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.amsabilitymultiinstanceappb.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "standard",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"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"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.amsabilitymultiinstanceappc",
"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
}
}
}
\ 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("ActsAmsAbilityMultiinstanceHapCRelyHap") {
hap_profile = "entry/src/main/module.json"
deps = [
":actsamsabilitymultiinstancehapc_js_assets",
":actsamsabilitymultiinstancehapc_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsAbilityMultiinstanceHapCRelyHap"
}
ohos_app_scope("actsamsabilitymultiinstancehapc_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsabilitymultiinstancehapc_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsamsabilitymultiinstancehapc_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsamsabilitymultiinstancehapc_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("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.application.Ability'
import commonEvent from '@ohos.commonevent'
var callBackSeq = "";
function publishCallBack() {
console.debug("====>AbilityMultiInstanceAppC Publish CallBack ====>");
}
async function onShowProcess() {
var abilityWant = globalThis.abilityWant;
var callBackData = "AppC:";
callBackData += callBackSeq;
var commonEventPublishData = {
data: callBackData,
parameters: abilityWant.parameters
};
console.log("AbilityMultiInstanceAppC onShowProcess")
if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) {
commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack);
} else {
commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => {
startAbilityProcess(globalThis.abilityContext, abilityWant.parameters);
});
}
callBackSeq = "";
}
async function startAbilityProcess(abilityContext, parameters) {
let bundleName = "com.example.amsabilitymultiinstanceappa";
let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility";
let idx = parameters.nextStep;
switch (parameters.step[idx]) {
case "StartA1":
parameters.startId = 1;
break;
case "StartA2":
parameters.startId = 2;
break;
case "StartB":
bundleName = "com.example.amsabilitymultiinstanceappb";
abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility";
break;
case "StartC":
bundleName = "com.example.amsabilitymultiinstanceappc";
abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility";
break;
case "StartDMain1":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 1;
break;
case "StartDMain2":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 2;
break;
case "StartDSec":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility";
break;
case "StartDThd":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility";
break;
case "StartE":
bundleName = "com.example.amsabilitymultiinstanceappe";
abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility";
break;
default:
break;
}
parameters.nextStep = ++idx;
abilityContext.startAbility({
bundleName: bundleName,
abilityName: abilityName,
parameters: parameters
}, (error, data) => {
console.log('AppC startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data))
})
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("MainAbility onCreate")
callBackSeq += "onCreate";
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("MainAbility onForeground")
callBackSeq += "onForeground";
onShowProcess();
}
onBackground() {
// Ability has back to background
console.log("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('Ability MultiInstance AppC')
.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": "com.example.amsabilitymultiinstanceappc",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.amsabilitymultiinstanceappc.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"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"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"
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.amsabilitymultiinstanceappd",
"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
}
}
}
\ 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("ActsAmsAbilityMultiinstanceHapDRelyHap") {
hap_profile = "entry/src/main/module.json"
deps = [
":actsamsabilitymultiinstancehapd_js_assets",
":actsamsabilitymultiinstancehapd_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsAbilityMultiinstanceHapDRelyHap"
}
ohos_app_scope("actsamsabilitymultiinstancehapd_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsabilitymultiinstancehapd_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsamsabilitymultiinstancehapd_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsamsabilitymultiinstancehapd_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests"
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
var onAcceptWantCalledSeq;
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("AbilityMultiInstanceAppD MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
onAcceptWant(want) {
console.log("AbilityMultiInstanceAppD onAcceptWant called want:" + JSON.stringify(want));
var abilityId = want.parameters.startId.toString();
onAcceptWantCalledSeq = "onAcceptWantCalled";
onAcceptWantCalledSeq += "Id";
onAcceptWantCalledSeq += abilityId;
globalThis.onAcceptWantCalledSeq = onAcceptWantCalledSeq;
globalThis.abilityWant = want;
console.log("AbilityMultiInstanceAppD set globalThis result :" + globalThis.onAcceptWantCalledSeq);
return abilityId;
}
}
\ 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.application.Ability'
import commonEvent from '@ohos.commonevent'
var callBackSeq = "";
function publishCallBack() {
console.debug("====>AbilityMultiInstanceAppD Publish CallBack ====>");
}
async function onShowProcess() {
var abilityWant = globalThis.abilityWant;
var callBackData = "AppD:";
callBackSeq += globalThis.onAcceptWantCalledSeq;
callBackData += callBackSeq;
var commonEventPublishData = {
data: callBackData,
parameters: abilityWant.parameters
};
console.log("AbilityMultiInstanceAppD abilityWant = " + JSON.stringify(abilityWant));
if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) {
commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack);
} else {
commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => {
startAbilityProcess(globalThis.abilityContext, abilityWant.parameters);
});
}
globalThis.onAcceptWantCalledSeq = "";
callBackSeq = "";
}
async function startAbilityProcess(abilityContext, parameters) {
let bundleName = "com.example.amsabilitymultiinstanceappa";
let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility";
let idx = parameters.nextStep;
switch (parameters.step[idx]) {
case "StartA1":
parameters.startId = 1;
break;
case "StartA2":
parameters.startId = 2;
break;
case "StartB":
bundleName = "com.example.amsabilitymultiinstanceappb";
abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility";
break;
case "StartC":
bundleName = "com.example.amsabilitymultiinstanceappc";
abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility";
break;
case "StartDMain1":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 1;
break;
case "StartDMain2":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 2;
break;
case "StartDSec":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility";
break;
case "StartDThd":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility";
break;
case "StartE":
bundleName = "com.example.amsabilitymultiinstanceappe";
abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility";
break;
default:
break;
}
parameters.nextStep = ++idx;
abilityContext.startAbility({
bundleName: bundleName,
abilityName: abilityName,
parameters: parameters
}, (error, data) => {
console.log('AppD startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data))
})
}
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceAppD onCreate")
callBackSeq += "onCreate";
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("AbilityMultiInstanceAppD onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("AbilityMultiInstanceAppD onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("AbilityMultiInstanceAppD onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("AbilityMultiInstanceAppD onForeground")
callBackSeq += "onForeground";
onShowProcess();
}
onBackground() {
// Ability has back to background
console.log("AbilityMultiInstanceAppD 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.application.Ability'
import commonEvent from '@ohos.commonevent'
var callBackSeq = "";
function publishCallBack() {
console.debug("====>AbilityMultiInstanceAppD Sec Publish CallBack ====>");
}
async function onShowProcess() {
var abilityWant = globalThis.abilityWant;
var callBackData = "AppD:";
callBackSeq += globalThis.onAcceptWantCalledSeq;
callBackData += callBackSeq;
var commonEventPublishData = {
data: callBackData,
parameters: abilityWant.parameters
};
console.log("AbilityMultiInstanceAppD Sec abilityWant = " + JSON.stringify(abilityWant));
if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) {
commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack);
} else {
commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => {
startAbilityProcess(globalThis.abilityContext, abilityWant.parameters);
});
}
globalThis.onAcceptWantCalledSeq = "";
callBackSeq = "";
}
async function startAbilityProcess(abilityContext, parameters) {
let bundleName = "com.example.amsabilitymultiinstanceappa";
let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility";
let idx = parameters.nextStep;
switch (parameters.step[idx]) {
case "StartA1":
parameters.startId = 1;
break;
case "StartA2":
parameters.startId = 2;
break;
case "StartB":
bundleName = "com.example.amsabilitymultiinstanceappb";
abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility";
break;
case "StartC":
bundleName = "com.example.amsabilitymultiinstanceappc";
abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility";
break;
case "StartDMain1":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 1;
break;
case "StartDMain2":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 2;
break;
case "StartDSec":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility";
break;
case "StartDThd":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility";
break;
case "StartE":
bundleName = "com.example.amsabilitymultiinstanceappe";
abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility";
break;
default:
break;
}
parameters.nextStep = ++idx;
abilityContext.startAbility({
bundleName: bundleName,
abilityName: abilityName,
parameters: parameters
}, (error, data) => {
console.log('AppD startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data))
})
}
export default class SecondAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceAppD Sec onCreate")
callBackSeq += "onCreate";
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("AbilityMultiInstanceAppD Sec onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("AbilityMultiInstanceAppD Sec onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("AbilityMultiInstanceAppD Sec onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("AbilityMultiInstanceAppD Sec onForeground")
callBackSeq += "onForeground";
onShowProcess();
}
onBackground() {
// Ability has back to background
console.log("AbilityMultiInstanceAppD Sec 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.application.Ability'
import commonEvent from '@ohos.commonevent'
var callBackSeq = "";
function publishCallBack() {
console.debug("====>AbilityMultiInstanceAppD Third Publish CallBack ====>");
}
async function onShowProcess() {
var abilityWant = globalThis.abilityWant;
var callBackData = "AppD:";
callBackSeq += globalThis.onAcceptWantCalledSeq;
callBackData += callBackSeq;
var commonEventPublishData = {
data: callBackData,
parameters: abilityWant.parameters
};
console.log("AbilityMultiInstanceAppD Third abilityWant = " + JSON.stringify(abilityWant));
if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) {
commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack);
} else {
commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => {
startAbilityProcess(globalThis.abilityContext, abilityWant.parameters);
});
}
globalThis.onAcceptWantCalledSeq = "";
callBackSeq = "";
}
async function startAbilityProcess(abilityContext, parameters) {
let bundleName = "com.example.amsabilitymultiinstanceappa";
let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility";
let idx = parameters.nextStep;
switch (parameters.step[idx]) {
case "StartA1":
parameters.startId = 1;
break;
case "StartA2":
parameters.startId = 2;
break;
case "StartB":
bundleName = "com.example.amsabilitymultiinstanceappb";
abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility";
break;
case "StartC":
bundleName = "com.example.amsabilitymultiinstanceappc";
abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility";
break;
case "StartDMain1":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 1;
break;
case "StartDMain2":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 2;
break;
case "StartDSec":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility";
break;
case "StartDThd":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility";
break;
default:
break;
}
parameters.nextStep = ++idx;
abilityContext.startAbility({
bundleName: bundleName,
abilityName: abilityName,
parameters: parameters
}, (error, data) => {
console.log('AppD startAbilityProcess result: ' + JSON.stringify(error) + ", " + JSON.stringify(data))
})
}
export default class ThirdAbility extends Ability {
onCreate(want, launchParam) {
// Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceAppD Third onCreate")
callBackSeq += "onCreate";
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("AbilityMultiInstanceAppD Third onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("AbilityMultiInstanceAppD Third onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("AbilityMultiInstanceAppD Third onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("AbilityMultiInstanceAppD Third onForeground")
callBackSeq += "onForeground";
onShowProcess();
}
onBackground() {
// Ability has back to background
console.log("AbilityMultiInstanceAppD Third 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('Ability MultiInstance AppC')
.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": "com.example.amsabilitymultiinstanceappd",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.amsabilitymultiinstanceappd.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "specified",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "com.example.amsabilitymultiinstanceappd.SecondAbility",
"srcEntrance": "./ets/SecondAbility/SecondAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"launchType": "standard",
"skills": [
{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}
]
},
{
"name": "com.example.amsabilitymultiinstanceappd.ThirdAbility",
"srcEntrance": "./ets/ThirdAbility/ThirdAbility.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"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"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"
}
]
}
\ 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("ActsAmsAbilityMultiinstanceHapERelyHap") {
hap_name = "ActsAmsAbilityMultiinstanceHapERelyHap"
hap_profile = "./src/main/config.json"
subsystem_name = XTS_SUITENAME
final_hap_path =
"${SUITES_OUTPUT_ROOT}/${XTS_SUITENAME}/testcases/${hap_name}.hap"
testonly = true
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./src/main/js/resources" ]
hap_profile = "./src/main/config.json"
}
{
"app": {
"bundleName": "com.example.amsabilitymultiinstanceappe",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5,
"releaseType": "Beta1"
}
},
"deviceConfig": {
"default": {
"process": "com.example.amsabilitymultiinstanceappe"
}
},
"module": {
"package": "com.example.amsabilitymultiinstanceappe",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.amsabilitymultiinstanceappe.MainAbility",
"visible": true,
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"reqPermissions": [
{
"name": "ohos.permission.INSTALL_BUNDLE",
"reason": "need use ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.MANAGE_MISSIONS",
"reason": "need use ohos.permission.MANAGE_MISSIONS"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO",
"reason": "need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason": "need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.REMOVE_CACHE_FILES",
"reason": "need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason": "need use ohos.permission.LISTEN_BUNDLE_CHANGE"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
\ 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.
*/
export default {
onCreate() {
console.info('ProcessManageSystemAppA onCreate');
},
onDestroy() {
console.info('ProcessManageSystemAppA onDestroy');
},
onShow() {
console.info('ProcessManageSystemAppA onShow');
},
onHide() {
console.info('ProcessManageSystemAppA onHide');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import featureAbility from '@ohos.ability.featureability'
import commonEvent from '@ohos.commonevent'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
var callBackSeq = "";
function publishCallBack() {
console.debug("====>AbilityMultiInstanceAppB Publish CallBack ====>");
}
async function startAbilityProcess(parameters) {
let bundleName = "com.example.amsabilitymultiinstanceappa";
let abilityName = "com.example.amsabilitymultiinstanceappa.MainAbility";
let idx = parameters.nextStep;
switch (parameters.step[idx]) {
case "StartA1":
parameters.startId = 1;
break;
case "StartA2":
parameters.startId = 2;
break;
case "StartB":
bundleName = "com.example.amsabilitymultiinstanceappb";
abilityName = "com.example.amsabilitymultiinstanceappb.MainAbility";
break;
case "StartC":
bundleName = "com.example.amsabilitymultiinstanceappc";
abilityName = "com.example.amsabilitymultiinstanceappc.MainAbility";
break;
case "StartDMain1":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 1;
break;
case "StartDMain2":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.MainAbility";
parameters.startId = 2;
break;
case "StartDSec":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.SecondAbility";
break;
case "StartDThd":
bundleName = "com.example.amsabilitymultiinstanceappd";
abilityName = "com.example.amsabilitymultiinstanceappd.ThirdAbility";
break;
case "StartE":
bundleName = "com.example.amsabilitymultiinstanceappe";
abilityName = "com.example.amsabilitymultiinstanceappe.MainAbility";
break;
default:
break;
}
parameters.nextStep = ++idx;
await featureAbility.startAbility({
want:
{
bundleName: bundleName,
abilityName: abilityName,
parameters: parameters
}
});
}
async function onShowProcess() {
var abilityWant = await featureAbility.getWant();
var callBackData = "AppE:";
callBackData += callBackSeq;
var commonEventPublishData = {
data: callBackData,
parameters: abilityWant.parameters
};
if (abilityWant.parameters.nextStep >= abilityWant.parameters.stepNum) {
commonEvent.publish("MultiInstanceStartFinish", commonEventPublishData, publishCallBack);
} else {
commonEvent.publish("MultiInstanceStartNext", commonEventPublishData, () => {
startAbilityProcess(abilityWant.parameters);
});
}
callBackSeq = "";
}
export default {
data: {
title: "AbilityMultiInstanceAppE"
},
onInit() {
this.title = "AbilityMultiInstanceAppE";
callBackSeq += "onInit";
},
onShow() {
console.log('AbilityMultiInstanceAppE onShow start');
callBackSeq += "onShow";
onShowProcess();
},
onStart() {
console.log('AbilityMultiInstanceAppE onStart');
},
onStop() {
console.log('AbilityMultiInstanceAppE onStop');
},
}
{
"string": [
{
"name": "app_name",
"value": "particlestartability"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
{
"app":{
"bundleName":"com.example.abilitymultiinstance",
"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("ActsAmsAbilityMultiinstanceTest") {
hap_profile = "entry/src/main/module.json"
deps = [
":actsamsabilitymultiinstance_js_assets",
":actsamsabilitymultiinstance_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsAmsAbilityMultiinstanceTest"
}
ohos_app_scope("actsamsabilitymultiinstance_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actsamsabilitymultiinstance_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actsamsabilitymultiinstance_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actsamsabilitymultiinstance_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1000000",
"package": "com.example.abilitymultiinstance",
"shell-timeout": "300000"
},
"kits": [
{
"test-file-name": [
"ActsAmsAbilityMultiinstanceTest.hap",
"ActsAmsAbilityMultiinstanceHapARelyHap.hap",
"ActsAmsAbilityMultiinstanceHapBRelyHap.hap",
"ActsAmsAbilityMultiinstanceHapCRelyHap.hap",
"ActsAmsAbilityMultiinstanceHapDRelyHap.hap",
"ActsAmsAbilityMultiinstanceHapERelyHap.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount"
]
},
{
"type": "ShellKit",
"run-command": [
"chmod 644 /data/*.hap"
]
}
]
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want,launchParam){
// Ability is creating, initialize resources for this ability
console.log("AbilityMultiInstanceTest onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
// Ability is destroying, release resources for this ability
console.log("AbilityMultiInstanceTest onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("AbilityMultiInstanceTest onWindowStageCreate")
globalThis.abilityContext = this.context
windowStage.setUIContent(this.context, "pages/index/index", null)
console.log("AbilityMultiInstanceTest onWindowStageCreate finish")
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("AbilityMultiInstanceTest onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("AbilityMultiInstanceTest onForeground")
}
onBackground() {
// Ability has back to background
console.log("AbilityMultiInstanceTest 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"
import testsuite from "../../test/List.test.ets"
@Entry
@Component
struct Index {
aboutToAppear() {
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters['timeout'] = 10000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Test App')
.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.
*/
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"
import testsuite from "../../test/List.test.ets"
@Entry
@Component
struct Index {
aboutToAppear(){
console.info("start run testcase!!!!")
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
const reportExtend = new ReportExtend(file)
core.addService('report', reportExtend)
core.init()
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
globalThis.abilityWant.parameters.timeout = 70000;
configService.setConfig(globalThis.abilityWant.parameters)
testsuite(globalThis.abilityContext)
core.execute()
}
build() {
Flex({ direction:FlexDirection.Column, alignItems:ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text('Hello World')
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(25)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.onClick(() => {
})
}
.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
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES 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(context) {
abilityTest(context)
}
\ No newline at end of file
{
"module": {
"name": "phone",
"type": "entry",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:phone_entry_dsc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [
{
"name": "com.example.abilitymultiinstance.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"
]
}
]
}
],
"requestPermissions": [
{
"name":"ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason":"need use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name":"ohos.permission.GET_BUNDLE_INFO",
"reason":"need use ohos.permission.GET_BUNDLE_INFO"
},
{
"name":"ohos.permission.CHANGE_ABILITY_ENABLED_STATE",
"reason":"need use ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name":"ohos.permission.REMOVE_CACHE_FILES",
"reason":"need use ohos.permission.REMOVE_CACHE_FILES"
},
{
"name":"ohos.permission.LISTEN_BUNDLE_CHANGE",
"reason":"need use ohos.permission.LISTEN_BUNDLE_CHANGE"
},
{
"name":"ohos.permission.INSTALL_BUNDLE",
"reason":"need use ohos.permission.INSTALL_BUNDLE"
},
{
"name":"ohos.permission.MANAGE_MISSIONS",
"reason":"need use ohos.permission.MANAGE_MISSIONS"
},
{
"name":"ohos.permission.GET_RUNNING_INFO",
"reason":"need use ohos.permission.GET_RUNNING_INFO"
},
{
"name":"ohos.permission.CLEAN_BACKGROUND_PROCESSES",
"reason":"need use ohos.permission.CLEAN_BACKGROUND_PROCESSES"
},
{
"name":"ohos.permission.CLEAN_APPLICATION_DATA",
"reason":"need use ohos.permission.CLEAN_APPLICATION_DATA"
}
]
}
}
{
"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"
}
]
}
# Copyright (c) 2022 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES 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_js_hap_suite("ActsSystemAppCalleeARelyHap") {
hap_profile = "entry/src/main/module.json"
deps = [
":systemappcalleea_js_assets",
":systemappcalleea_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsSystemAppCalleeARelyHap"
}
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"
}
{
"description": "Configuration for hjunit demo Tests"
}
\ 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.application.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.application.Ability'
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.application.Ability'
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.application.Ability'
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
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册