提交 7be13e8d 编写于 作者: D dy

add actslifecyclesinglehaptest and actslifecyclemultihaptest

Signed-off-by: Ndy <dingyao5@huawei.com>
上级 c02c1604
......@@ -23,15 +23,16 @@ group("aafwk_standard") {
"actsabilitylifecyclestatenew:ActsAbilityLifecycleStateNewTest",
"actsabilitymanageretstest:ActsAbilityManagerEtsTest",
"actsdataabilityjs:ActsDataAbilityJsTest",
"actsfwkdataaccessortest:dataability",
"actsserviceabilityclienttest:serviceability",
"actsstserviceabilityclientcase:ActsStServiceAbilityClientCaseTest",
"amsabilitymanager:amsabilitymanager",
"amsabilitymanager/amsMissionSnapshotTest:ActsAmsMissionSnapshotTest",
"amsabilitymanager/amsMissionSnapshotTestSingleton:ActsAmsMissionSnapshotTestSingleton",
"amsabilitymanager/amsMissionSnapshotTestSingletonS:ActsAmsMissionSnapshotTestSingletonS",
"amsdatauriutils:ActsAmsDataUriUtilsTest",
"amsgetabilityprocessinfo:amsgetabilityprocessinfo",
"context:context",
"featureability:featureability",
"formmanager:formmanager",
"stage:stage",
"want:want",
]
}
......
# 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("stage") {
testonly = true
if (is_standard_system) {
deps = [
"actslifecyclemultihap2test:ActsLifecycleMultiHap2Test",
"actslifecyclemultihap3test:ActsLifecycleMultiHap3Test",
"actslifecyclemultihaptest:ActsLifecycleMultiHapTest",
"actslifecyclesinglehaptest:ActsLifecycleSingleHapTest",
]
}
}
{
"app": {
"bundleName": "com.example.lifecycletest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"LifecycleHap2Test"
}
]
}
\ No newline at end of file
# 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")
ohos_js_hap_suite("ActsLifecycleMultiHap2Test") {
hap_profile = "entry/src/main/module.json"
deps = [
":actslifecyclemultihap2test_js_assets",
":actslifecyclemultihap2test_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsLifecycleMultiHap2Test"
}
ohos_app_scope("actslifecyclemultihap2test_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actslifecyclemultihap2test_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actslifecyclemultihap2test_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actslifecyclemultihap2test_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.lifecycletest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsLifecycleMultiHap2Test.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility1 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] Hap2MainAbility1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility1 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility1_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility1 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility10 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility10 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] Hap2MainAbility10 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility10 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility10_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility10 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility10 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility10 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility2 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] Hap2MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility2 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility2_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility2 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility3 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility3 onCreate")
globalThis.abilityWant = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap2MainAbility3 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap2MainAbility3 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap2MainAbility3 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility3 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility3_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility3 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility3 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility3 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility4 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility4 onCreate")
globalThis.abilityWant = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap2MainAbility4 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap2MainAbility4 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap2MainAbility4 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility4 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility4_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility4 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility4 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility4 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility5 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility5 onCreate")
globalThis.abilityWant = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap2MainAbility5 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap2MainAbility5 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap2MainAbility5 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility5 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility5_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility5 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility5 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility5 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility6 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility6 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] Hap2MainAbility6 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility6 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility6_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility6 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility6 onForeground")
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap2MainAbility6 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap2MainAbility6 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility6 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility7 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility7 onCreate")
globalThis.abilityWant = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap2MainAbility7 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap2MainAbility7 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap2MainAbility7 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility7 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility7_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility7 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility7 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility7 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility8 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility8 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] Hap2MainAbility8 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility8 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility8_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resourcesl
console.log("[Demo] Hap2MainAbility8 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility8 onForeground")
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap2MainAbility8 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap2MainAbility8 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 500)
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility8 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap2MainAbility9 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap2MainAbility9 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] Hap2MainAbility9 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap2MainAbility9 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap2MainAbility9_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap2MainAbility9 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap2MainAbility9 onForeground")
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap2MainAbility9 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap2MainAbility9 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 500)
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap2MainAbility9 onBackground")
}
};
/*
* 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.
*/
@Entry
@Component
struct Hap2MainAbility10_pages {
@State message: string = 'Hap2MainAbility10'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct Hap2MainAbility1_pages {
@State message: string = 'Hap2MainAbility1'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 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.
*/
@Entry
@Component
struct Hap2MainAbility2_pages {
@State message: string = 'Hap2MainAbility2'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 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.
*/
@Entry
@Component
struct Hap2MainAbility3_pages {
@State message: string = 'Hap2MainAbility3'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 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.
*/
@Entry
@Component
struct Hap2MainAbility4_pages {
@State message: string = 'Hap2MainAbility4'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (c) 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.
*/
@Entry
@Component
struct Hap2MainAbility5_pages {
@State message: string = 'Hap2MainAbility5'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct Hap2MainAbility6_pages {
@State message: string = 'Hap2MainAbility6'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct Hap2MainAbility7_pages {
@State message: string = 'Hap2MainAbility7'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct Hap2MainAbility8_pages {
@State message: string = 'Hap2MainAbility8'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct Hap2MainAbility9_pages {
@State message: string = 'Hap2MainAbility9'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "hap2",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:hap2_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.lifecycletest.Hap2MainAbility1",
"srcEntrance": "./ets/Hap2MainAbility1/Hap2MainAbility1.ts",
"description": "$string:Hap2MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility1_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
},
{
"name": "Hap2MainAbility2",
"srcEntrance": "./ets/Hap2MainAbility2/Hap2MainAbility2.ts",
"description": "$string:Hap2MainAbility2_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility2_label"
},
{
"name": "Hap2MainAbility3",
"srcEntrance": "./ets/Hap2MainAbility3/Hap2MainAbility3.ts",
"description": "$string:Hap2MainAbility3_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility3_label"
},
{
"name": "Hap2MainAbility4",
"srcEntrance": "./ets/Hap2MainAbility4/Hap2MainAbility4.ts",
"description": "$string:Hap2MainAbility4_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility4_label",
"launchType": "singleton"
},
{
"name": "Hap2MainAbility5",
"srcEntrance": "./ets/Hap2MainAbility5/Hap2MainAbility5.ts",
"description": "$string:Hap2MainAbility5_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility5_label",
"launchType": "standard"
},
{
"name": "Hap2MainAbility6",
"srcEntrance": "./ets/Hap2MainAbility6/Hap2MainAbility6.ts",
"description": "$string:Hap2MainAbility6_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility6_label"
},
{
"name": "Hap2MainAbility7",
"srcEntrance": "./ets/Hap2MainAbility7/Hap2MainAbility7.ts",
"description": "$string:Hap2MainAbility7_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility7_label"
},
{
"name": "Hap2MainAbility8",
"srcEntrance": "./ets/Hap2MainAbility8/Hap2MainAbility8.ts",
"description": "$string:Hap2MainAbility8_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility8_label"
},
{
"name": "Hap2MainAbility9",
"srcEntrance": "./ets/Hap2MainAbility9/Hap2MainAbility9.ts",
"description": "$string:Hap2MainAbility9_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility9_label"
},
{
"name": "Hap2MainAbility10",
"srcEntrance": "./ets/Hap2MainAbility10/Hap2MainAbility10.ts",
"description": "$string:Hap2MainAbility10_desc",
"icon": "$media:icon",
"label": "$string:Hap2MainAbility10_label"
}],
"requestPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.MANAGE_MISSIONS"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsLifecycleMultihapTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "entry_desc",
"value": "description"
},
{
"name": "hap2_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "Hap2MainAbility1_desc",
"value": "description"
},
{
"name": "Hap2MainAbility1_label",
"value": "label"
},
{
"name": "Hap2MainAbility2_desc",
"value": "description"
},
{
"name": "Hap2MainAbility2_label",
"value": "label"
},
{
"name": "Hap2MainAbility3_desc",
"value": "description"
},
{
"name": "Hap2MainAbility3_label",
"value": "label"
},
{
"name": "Hap2MainAbility4_desc",
"value": "description"
},
{
"name": "Hap2MainAbility4_label",
"value": "label"
},
{
"name": "Hap2MainAbility5_desc",
"value": "description"
},
{
"name": "Hap2MainAbility5_label",
"value": "label"
},
{
"name": "Hap2MainAbility6_desc",
"value": "description"
},
{
"name": "Hap2MainAbility6_label",
"value": "label"
},
{
"name": "Hap2MainAbility7_desc",
"value": "description"
},
{
"name": "Hap2MainAbility7_label",
"value": "label"
},
{
"name": "Hap2MainAbility8_desc",
"value": "description"
},
{
"name": "Hap2MainAbility8_label",
"value": "label"
},
{
"name": "Hap2MainAbility9_desc",
"value": "description"
},
{
"name": "Hap2MainAbility9_label",
"value": "label"
},
{
"name": "Hap2MainAbility10_desc",
"value": "description"
},
{
"name": "Hap2MainAbility10_label",
"value": "label"
}
]
}
{
"src": [
"pages/Hap2MainAbility1_pages",
"pages/Hap2MainAbility2_pages",
"pages/Hap2MainAbility3_pages",
"pages/Hap2MainAbility4_pages",
"pages/Hap2MainAbility5_pages",
"pages/Hap2MainAbility6_pages",
"pages/Hap2MainAbility7_pages",
"pages/Hap2MainAbility8_pages",
"pages/Hap2MainAbility9_pages",
"pages/Hap2MainAbility10_pages"
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.lifecycletest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"LifecycleHap3Test"
}
]
}
\ No newline at end of file
# 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")
ohos_js_hap_suite("ActsLifecycleMultiHap3Test") {
hap_profile = "entry/src/main/module.json"
deps = [
":actslifecyclemultihap3test_js_assets",
":actslifecyclemultihap3test_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsLifecycleMultiHap3Test"
}
ohos_app_scope("actslifecyclemultihap3test_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actslifecyclemultihap3test_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actslifecyclemultihap3test_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actslifecyclemultihap3test_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.lifecycletest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsLifecycleMultiHap3Test.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* 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 commonEvent from '@ohos.commonEvent';
import Ability from '@ohos.application.Ability'
export default class Hap3MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap3MainAbility1 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] Hap3MainAbility1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap3MainAbility1 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap3MainAbility1_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap3MainAbility1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap3MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap3MainAbility1 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap3MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap3MainAbility2 onCreate")
globalThis.abilityWant = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap3MainAbility2 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap3MainAbility2 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap3MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap3MainAbility2 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap3MainAbility2_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap3MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap3MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap3MainAbility2 onBackground")
}
};
/*
* 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 commonEvent from '@ohos.commonEvent';
import Ability from '@ohos.application.Ability'
export default class Hap3MainAbility3 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap3MainAbility3 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] Hap3MainAbility3 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap3MainAbility3 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap3MainAbility3_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap3MainAbility3 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap3MainAbility3 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap3MainAbility3 onBackground")
}
};
/*
* 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.
*/
@Entry
@Component
struct Hap3MainAbility1_pages {
@State message: string = 'Hap3MainAbility1'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct Hap3MainAbility2_pages {
@State message: string = 'Hap3MainAbility2'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct Hap3MainAbility3_pages {
@State message: string = 'Hap3MainAbility3'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "hap3",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:hap3_desc",
"mainElement": "MainAbility",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.lifecycletest.Hap3MainAbility1",
"srcEntrance": "./ets/Hap3MainAbility1/Hap3MainAbility1.ts",
"description": "$string:Hap3MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:Hap3MainAbility1_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
},
{
"name": "Hap3MainAbility2",
"srcEntrance": "./ets/Hap3MainAbility2/Hap3MainAbility2.ts",
"description": "$string:Hap3MainAbility2_desc",
"icon": "$media:icon",
"label": "$string:Hap3MainAbility2_label"
},
{
"name": "Hap3MainAbility3",
"srcEntrance": "./ets/Hap3MainAbility3/Hap3MainAbility3.ts",
"description": "$string:Hap3MainAbility3_desc",
"icon": "$media:icon",
"label": "$string:Hap3MainAbility3_label"
}],
"requestPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.MANAGE_MISSIONS"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsLifecycleMultihapTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "hap3_desc",
"value": "description"
},
{
"name": "Hap3MainAbility1_desc",
"value": "description"
},
{
"name": "Hap3MainAbility1_label",
"value": "label"
},
{
"name": "Hap3MainAbility2_desc",
"value": "description"
},
{
"name": "Hap3MainAbility2_label",
"value": "label"
},
{
"name": "Hap3MainAbility3_desc",
"value": "description"
},
{
"name": "Hap3MainAbility3_label",
"value": "label"
}
]
}
{
"src": [
"pages/Hap3MainAbility1_pages",
"pages/Hap3MainAbility2_pages",
"pages/Hap3MainAbility3_pages"
]
}
{
"app": {
"bundleName": "com.example.lifecycletest",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"LifecycleTest"
}
]
}
\ No newline at end of file
# 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")
ohos_js_hap_suite("ActsLifecycleMultiHapTest") {
hap_profile = "entry/src/main/module.json"
deps = [
":actslifecyclemultihaptest_js_assets",
":actslifecyclemultihaptest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsLifecycleMultiHapTest"
}
ohos_app_scope("actslifecyclemultihaptest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actslifecyclemultihaptest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actslifecyclemultihaptest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actslifecyclemultihaptest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.lifecycletest",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsLifecycleMultiHapTest.hap",
"ActsLifecycleMultiHap2Test.hap",
"ActsLifecycleMultiHap3Test.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
globalThis.stageOnCreateRun = 1;
globalThis.stageContext = this.context;
}
}
\ No newline at end of file
/*
* 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 Ability from '@ohos.application.Ability'
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility1 onCreate")
globalThis.abilityWant = want;
var listKey = [];
var abilityName = "";
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityCreate")
listKey.push(abilityName +" onAbilityCreate");
console.log("listKey is :" + listKey);
},
onAbilityWindowStageCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityWindowStageCreate")
listKey.push(abilityName +" onAbilityWindowStageCreate");
console.log("listKey is :" + listKey);
},
onAbilityForeground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityForeground")
listKey.push(abilityName +" onAbilityForeground");
console.log("listKey is :" + listKey);
},
onAbilityBackground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityBackground")
listKey.push(abilityName +" onAbilityBackground");
console.log("listKey is :" + listKey);
},
onAbilityWindowStageDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityWindowStageDestroy")
listKey.push(abilityName +" onAbilityWindowStageDestroy");
console.log("listKey is :" + listKey);
},
onAbilityDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityDestroy")
listKey.push(abilityName +" onAbilityDestroy");
console.log("listKey is :" + listKey);
},
onAbilityContinue(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityContinue")
listKey.push(abilityName +" onAbilityContinue");
console.log("listKey is :" + listKey);
}
}
globalThis.mainAbility1ListKey = listKey
var callBackId = this.context.getApplicationContext().registerAbilityLifecycleCallback(AbilityLifecycleCallback);
globalThis.mainAbility1CallBackId = callBackId
setTimeout(() => {
console.log("listKey is :" + listKey);
console.log("callBackId is :" + callBackId);
this.context.getApplicationContext().unregisterAbilityLifecycleCallback (callBackId, (error, data)=> {
console.log("unRegisterAbilityLifecycleCallback err is :" +
JSON.stringify(error) + ",data is : " + JSON.stringify(data))
});
}, 4000)
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.log("[Demo] MainAbility1 terminateSelf windowStage data: " + JSON.stringify(data))
}).catch((error) => {
console.log("[Demo] MainAbility1 terminateSelf windowStage error: " + JSON.stringify(error))
})
}, 3000)
}
onDestroy() {
console.log("[Demo] MainAbility1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility1 onWindowStageCreate")
globalThis.ability2Context = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility1_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility1 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility2 onCreate")
globalThis.abilityWant = want;
var listKey = [];
var abilityName = "";
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityCreate")
listKey.push(abilityName +" onAbilityCreate");
console.log("listKey is :" + listKey);
},
onAbilityWindowStageCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityWindowStageCreate")
listKey.push(abilityName +" onAbilityWindowStageCreate");
console.log("listKey is :" + listKey);
},
onAbilityForeground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityForeground")
listKey.push(abilityName +" onAbilityForeground");
console.log("listKey is :" + listKey);
},
onAbilityBackground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityBackground")
listKey.push(abilityName +" onAbilityBackground");
console.log("listKey is :" + listKey);
},
onAbilityWindowStageDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityWindowStageDestroy")
listKey.push(abilityName +" onAbilityWindowStageDestroy");
console.log("listKey is :" + listKey);
},
onAbilityDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityDestroy")
listKey.push(abilityName +" onAbilityDestroy");
console.log("listKey is :" + listKey);
},
onAbilityContinue(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityContinue")
listKey.push(abilityName +" onAbilityContinue");
console.log("listKey is :" + listKey);
}
}
var callBackId = this.context.getApplicationContext().registerAbilityLifecycleCallback(AbilityLifecycleCallback);
setTimeout(() => {
globalThis.mainAbility2ListKey = listKey
globalThis.mainAbility2CallBackId = callBackId
console.log("listKey is :" + listKey);
console.log("callBackId is :" + callBackId);
}, 3000)
}
onDestroy() {
console.log("[Demo] MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility2 onWindowStageCreate")
globalThis.ability3Context = this.context;
windowStage.setUIContent(this.context, "pages/MainAbility2_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility onBackground")
}
};
/*
* 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 commonEvent from '@ohos.commonEvent';
import Ability from '@ohos.application.Ability'
export default class MainAbility3 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility3 onCreate")
globalThis.abilityWant = want;
var getauxMainAbilityContext = {
events: ["auxMainAbilityContext"]
}
var a;
function SubscribeCallBackContext(err, data) {
console.log(" Subscribe CallBack data:" + JSON.stringify(data));
a = data.parameters;
if(data.event != ""){
for (var key in data.parameters){
console.log("data.parameters[key] is :" + data.parameters[key])
}
}
}
commonEvent.createSubscriber(getauxMainAbilityContext).then(async (data) => {
console.debug("====>Create Subscriber====>");
var Subscriber = data;
await commonEvent.subscribe(Subscriber, SubscribeCallBackContext);
});
var listKey = [];
var abilityName = "";
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityCreate")
listKey.push(abilityName +" onAbilityCreate");
console.log("listKey is :" + listKey);
},
onAbilityWindowStageCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityWindowStageCreate")
listKey.push(abilityName +" onAbilityWindowStageCreate");
console.log("listKey is :" + listKey);
},
onAbilityForeground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityForeground")
listKey.push(abilityName +" onAbilityForeground");
console.log("listKey is :" + listKey);
},
onAbilityBackground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityBackground")
listKey.push(abilityName +" onAbilityBackground");
console.log("listKey is :" + listKey);
},
onAbilityWindowStageDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityWindowStageDestroy")
listKey.push(abilityName +" onAbilityWindowStageDestroy");
console.log("listKey is :" + listKey);
},
onAbilityDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityDestroy")
listKey.push(abilityName +" onAbilityDestroy");
console.log("listKey is :" + listKey);
},
onAbilityContinue(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName +" onAbilityContinue")
listKey.push(abilityName +" onAbilityContinue");
console.log("listKey is :" + listKey);
}
}
setTimeout(() => {
console.log("mainAbility3ListKey a is : " + JSON.stringify(a))
//TODO:
var callBackId = a.auxMainAbilityContext.getApplicationContext().
registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("mainAbility3ListKey callBackId is : " + callBackId)
globalThis.mainAbility3ListKey = listKey
console.log("mainAbility3ListKey mainAbility3ListKey is : " + globalThis.mainAbility3ListKey)
globalThis.mainAbility3CallBackId = callBackId
console.log("mainAbility3ListKey listKey is :" + listKey);
console.log("mainAbility3ListKey globalThis.callBackId is :" + globalThis.callBackId);
}, 3000)
}
onDestroy() {
console.log("[Demo] MainAbility3 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility3 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/MainAbility3_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility3 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility3 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility3 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class MainAbility4 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility4 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility4 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility4 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/MainAbility4_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility4 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility4 onForeground")
var listKey = [];
var abilityName = "";
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityCreate")
listKey.push(abilityName+" onAbilityCreate");
},
onAbilityWindowStageCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityWindowStageCreate")
listKey.push(abilityName+" onAbilityWindowStageCreate");
},
onAbilityForeground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityForeground")
listKey.push(abilityName+" onAbilityForeground");
},
onAbilityBackground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityBackground")
listKey.push(abilityName+" onAbilityBackground");
},
onAbilityWindowStageDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityWindowStageDestroy")
listKey.push(abilityName+" onAbilityWindowStageDestroy");
},
onAbilityDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityDestroy")
listKey.push(abilityName+" onAbilityDestroy");
},
onAbilityContinue(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityContinue")
listKey.push(abilityName+" onAbilityContinue");
}
}
var callBackId = this.context.getApplicationContext().registerAbilityLifecycleCallback(AbilityLifecycleCallback);
globalThis.abilityContext111 = this.context;
console.log("callBackId is aaa :" + callBackId);
setTimeout(() => {
globalThis.mainAbility4ListKey = listKey
globalThis.mainAbility4CallBackId = callBackId
console.log("listKey is :" + listKey);
console.log("callBackId is :" + callBackId);
}, 3000)
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility4 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class MainAbility5 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility5 onCreate")
globalThis.abilityWant = want;
var listKey = [];
var abilityName = "";
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityCreate")
listKey.push(abilityName+" onAbilityCreate");
},
onAbilityWindowStageCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityWindowStageCreate")
listKey.push(abilityName+" onAbilityWindowStageCreate");
},
onAbilityForeground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityForeground")
listKey.push(abilityName+" onAbilityForeground");
},
onAbilityBackground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityBackground")
listKey.push(abilityName+" onAbilityBackground");
},
onAbilityWindowStageDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityWindowStageDestroy")
listKey.push(abilityName+" onAbilityWindowStageDestroy");
},
onAbilityDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityDestroy")
listKey.push(abilityName+" onAbilityDestroy");
},
onAbilityContinue(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityContinue")
listKey.push(abilityName+" onAbilityContinue");
}
}
var callBackId = this.context.getApplicationContext().registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("callBackId is aaa :" + callBackId);
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap2MainAbility6 EventTest terminateSelf data: " + JSON.stringify(data));
globalThis.mainAbility5ListKey = listKey
globalThis.mainAbility5CallBackId = callBackId
console.log("listKey is :" + listKey);
console.log("callBackId is :" + callBackId);
}).catch((error) => {
console.log("Hap2MainAbility6 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 1000)
}
onDestroy() {
console.log("[Demo] MainAbility5 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility5 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/MainAbility5_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility5 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility5 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility5 onBackground")
}
};
/*
* 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 Ability from '@ohos.application.Ability'
export default class MainAbility6 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility6 onCreate")
globalThis.abilityWant = want;
var listKey = [];
var abilityName = "";
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityCreate")
listKey.push(abilityName+" onAbilityCreate");
},
onAbilityWindowStageCreate(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityWindowStageCreate")
listKey.push(abilityName+" onAbilityWindowStageCreate");
},
onAbilityForeground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityForeground")
listKey.push(abilityName+" onAbilityForeground");
},
onAbilityBackground(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityBackground")
listKey.push(abilityName+" onAbilityBackground");
},
onAbilityWindowStageDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityWindowStageDestroy")
listKey.push(abilityName+" onAbilityWindowStageDestroy");
},
onAbilityDestroy(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityDestroy")
listKey.push(abilityName+" onAbilityDestroy");
},
onAbilityContinue(ability) {
abilityName = ability.context.abilityInfo.name;
console.log(abilityName+" onAbilityContinue")
listKey.push(abilityName+" onAbilityContinue");
}
}
var callBackId = this.context.getApplicationContext().registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("callBackId is aaa :" + callBackId);
setTimeout(() => {
globalThis.mainAbility6ListKey = listKey
globalThis.mainAbility6CallBackId = callBackId
console.log("listKey is :" + listKey);
console.log("callBackId is :" + callBackId);
}, 3000)
}
onDestroy() {
console.log("[Demo] MainAbility6 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility6 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/MainAbility6_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility6 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility6 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility6 onBackground")
}
};
// @ts-nocheck
/*
* 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.
*/
@Entry
@Component
struct MainAbility1_pages {
@State message: string = 'MainAbility1'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
// @ts-nocheck
/*
* 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.
*/
@Entry
@Component
struct MainAbility2_pages {
@State message: string = 'MainAbility2'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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.
*/
@Entry
@Component
struct MainAbility3_pages {
@State message: string = 'MainAbility3_pages'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
// @ts-nocheck
/*
* 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.
*/
@Entry
@Component
struct MainAbility4_pages {
@State message: string = 'MainAbility4'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
// @ts-nocheck
/*
* 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.
*/
@Entry
@Component
struct MainAbility5_pages {
@State message: string = 'MainAbility5'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
// @ts-nocheck
/*
* 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.
*/
@Entry
@Component
struct MainAbility6_pages {
@State message: string = 'MainAbility6'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
// @ts-nocheck
/*
* 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 file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"
import list from '../test/ListTest'
@Entry
@Component
struct Index {
@State message: string = 'MainAbility'
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()
globalThis.abilityWant.parameters.timeout = 20000;
core.subscribeEvent('task', reportExtend)
const configService = core.getDefaultService('config')
configService.setConfig(globalThis.abilityWant.parameters)
console.info('parameters---->' + JSON.stringify(globalThis.abilityWant.parameters))
list(globalThis.abilityContext)
core.execute()
}
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* 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 lifecycleTest from './LifecycleTest'
export default function List(context) {
lifecycleTest(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.lifecycletest.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
"description": "$string:phone_entry_main",
"icon": "$media:icon",
"label": "$string:entry_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
},
{
"name": "MainAbility1",
"srcEntrance": "./ets/MainAbility1/MainAbility1.ts",
"description": "$string:MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:MainAbility1_label"
},
{
"name": "MainAbility2",
"srcEntrance": "./ets/MainAbility2/MainAbility2.ts",
"description": "$string:MainAbility2_desc",
"icon": "$media:icon",
"label": "$string:MainAbility2_label"
},
{
"name": "MainAbility3",
"srcEntrance": "./ets/MainAbility3/MainAbility3.ts",
"description": "$string:MainAbility3_desc",
"icon": "$media:icon",
"label": "$string:MainAbility3_label"
},
{
"name": "MainAbility4",
"srcEntrance": "./ets/MainAbility4/MainAbility4.ts",
"description": "$string:MainAbility4_desc",
"icon": "$media:icon",
"label": "$string:MainAbility4_label"
},
{
"name": "MainAbility5",
"srcEntrance": "./ets/MainAbility5/MainAbility5.ts",
"description": "$string:MainAbility5_desc",
"icon": "$media:icon",
"label": "$string:MainAbility5_label"
},
{
"name": "MainAbility6",
"srcEntrance": "./ets/MainAbility6/MainAbility6.ts",
"description": "$string:MainAbility6_desc",
"icon": "$media:icon",
"label": "$string:MainAbility6_label",
"launchType": "standard"
}],
"requestPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.MANAGE_MISSIONS"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsLifecycleMultihapTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "MainAbility1_desc",
"value": "description"
},
{
"name": "MainAbility1_label",
"value": "label"
},
{
"name": "MainAbility2_desc",
"value": "description"
},
{
"name": "MainAbility2_label",
"value": "label"
},
{
"name": "MainAbility3_desc",
"value": "description"
},
{
"name": "MainAbility3_label",
"value": "label"
},
{
"name": "MainAbility4_desc",
"value": "description"
},
{
"name": "MainAbility4_label",
"value": "label"
},
{
"name": "MainAbility5_desc",
"value": "description"
},
{
"name": "MainAbility5_label",
"value": "label"
},
{
"name": "MainAbility6_desc",
"value": "description"
},
{
"name": "MainAbility6_label",
"value": "label"
}
]
}
{
"src": [
"pages/MainAbility_pages",
"pages/MainAbility1_pages",
"pages/MainAbility2_pages",
"pages/MainAbility3_pages",
"pages/MainAbility4_pages",
"pages/MainAbility5_pages",
"pages/MainAbility6_pages"
]
}
\ No newline at end of file
/*
* 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 AbilityStage from "@ohos.application.AbilityStage"
export default class MyAbilityStage extends AbilityStage {
onCreate() {
console.log("[Demo] MyAbilityStage onCreate")
}
}
\ No newline at end of file
/*
* 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 Ability from '@ohos.application.Ability'
export default class Hap4MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap4MainAbility1 onCreate")
globalThis.abilityWant = want;
setTimeout(()=>{
this.context.terminateSelf().then((data) => {
console.log("[Demo] Hap4MainAbility1 terminateSelf windowStage data: " + JSON.stringify(data))
}).catch((error) => {
console.log("[Demo] Hap4MainAbility1 terminateSelf windowStage error: " + JSON.stringify(error))
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap4MainAbility1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap4MainAbility1 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/Hap4MainAbility1_pages", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap4MainAbility1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap4MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap4MainAbility1 onBackground")
}
};
/*
* 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.
*/
@Entry
@Component
struct Index {
@State message: string = 'Hap4MainAbility1'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
{
"module": {
"name": "hap4",
"type": "feature",
"srcEntrance": "./ets/Application/AbilityStage.ts",
"description": "$string:hap4_desc",
"mainElement": "Hap4MainAbility1",
"deviceTypes": [
"phone"
],
"deliveryWithInstall": true,
"installationFree": false,
"uiSyntax": "ets",
"process": "hap4mainability",
"pages": "$profile:main_pages",
"abilities": [{
"name": "com.example.lifecycletest.hap4mainability",
"srcEntrance": "./ets/hap4mainability/hap4mainability.ts",
"description": "$string:Hap4MainAbility1_desc",
"icon": "$media:icon",
"label": "$string:Hap4MainAbility1_label",
"visible": true,
"orientation": "portrait",
"skills": [{
"actions": [
"action.system.home"
],
"entities": [
"entity.system.home"
]
}]
}],
"requestPermissions": [
{
"name": "ohos.permission.GET_BUNDLE_INFO"
},
{
"name": "ohos.permission.MANAGE_MISSIONS"
},
{
"name": "ohos.permission.INSTALL_BUNDLE"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.CHANGE_ABILITY_ENABLED_STATE"
},
{
"name": "ohos.permission.REMOVE_CACHE_FILES"
},
{
"name": "ohos.permission.LISTEN_BUNDLE_CHANGE"
}
]
}
}
\ No newline at end of file
{
"string": [
{
"name": "phone_entry_dsc",
"value": "i am an entry for phone"
},
{
"name": "phone_entry_main",
"value": "the phone entry ability"
},
{
"name": "entry_label",
"value": "ActsLifecycleMultihapTest"
},
{
"name": "form_description",
"value": "my form"
},
{
"name": "description_application",
"value": "demo for test"
},
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "hap4_desc",
"value": "description"
},
{
"name": "Hap4MainAbility1_desc",
"value": "description"
},
{
"name": "Hap4MainAbility1_label",
"value": "label"
}
]
}
{
"app": {
"bundleName": "com.example.lifecycle_xts",
"vendor": "huawei",
"versionCode": 1000000,
"versionName": "1.0.0",
"debug": false,
"icon": "$media:icon",
"label": "$string:app_name",
"description": "$string:description_application",
"distributedNotificationEnabled": true,
"keepAlive": true,
"singleUser": true,
"minAPIVersion": 9,
"targetAPIVersion": 9,
"car": {
"apiCompatibleVersion": 9,
"singleUser": false
}
}
}
{
"string":[
{
"name":"app_name",
"value":"LifeCycle_XTS"
}
]
}
\ No newline at end of file
# 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")
ohos_js_hap_suite("ActsLifecycleSingleHapTest") {
hap_profile = "entry/src/main/module.json"
deps = [
":actslifecyclesinglehaptest_js_assets",
":actslifecyclesinglehaptest_resources",
]
ets2abc = true
certificate_profile = "signature/openharmony_sx.p7b"
hap_name = "ActsLifecycleSingleHapTest"
}
ohos_app_scope("actslifecyclesinglehaptest_app_profile") {
app_profile = "AppScope/app.json"
sources = [ "AppScope/resources" ]
}
ohos_js_assets("actslifecyclesinglehaptest_js_assets") {
source_dir = "entry/src/main/ets"
}
ohos_resources("actslifecyclesinglehaptest_resources") {
sources = [ "entry/src/main/resources" ]
deps = [ ":actslifecyclesinglehaptest_app_profile" ]
hap_profile = "entry/src/main/module.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "180000",
"package": "com.example.lifecycle_xts",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsLifecycleSingleHapTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
/*
* 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("[Demo] MyAbilityStage onCreate")
console.log("[Demo] MyAbilityStage stagecontext: " + JSON.stringify(this.context));
var listKey = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey:" + JSON.stringify(listKey));
},
onAbilityWindowStageCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityWindowStageCreate");
listKey.push(abilityname + " onAbilityWindowStageCreate");
console.log("[Demo] 2listKey:" + JSON.stringify(listKey));
},
onAbilityWindowStageDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityWindowStageDestroy");
listKey.push(abilityname + " onAbilityWindowStageDestroy");
console.log("[Demo] 3listKey:" + JSON.stringify(listKey));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey:" + JSON.stringify(listKey));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey:" + JSON.stringify(listKey));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey:" + JSON.stringify(listKey));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey:" + JSON.stringify(listKey));
}
}
let applicationContext = this.context.getApplicationContext();
console.log("[Demo] stage applicationContext: " + JSON.stringify(applicationContext));
let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] AbilityLifecycleCallback listKey : " + JSON.stringify(listKey));
globalThis.list = listKey;
globalThis.callbackid = lifecycleid;
}, 2000);
}
}
\ 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'
export default class Hap1MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap1MainAbility1 onCreate")
globalThis.abilityWant = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap1MainAbility1 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap1MainAbility1 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap1MainAbility1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap1MainAbility1 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/indexh1a1", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap1MainAbility1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap1MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap1MainAbility1 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'
export default class Hap1MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] Hap1MainAbility2 onCreate")
globalThis.abilityWant = want;
setTimeout(() => {
this.context.terminateSelf().then((data) => {
console.log("Hap1MainAbility2 EventTest terminateSelf data: " + JSON.stringify(data));
}).catch((error) => {
console.log("Hap1MainAbility2 EventTest terminateSelf error: " + JSON.stringify(error));
})
}, 2000)
}
onDestroy() {
console.log("[Demo] Hap1MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] Hap1MainAbility2 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/indexh1a2", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] Hap1MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] Hap1MainAbility2 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] Hap1MainAbility2 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 Ability from '@ohos.application.Ability';
export default class MainAbility extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility onWindowStageCreate")
globalThis.abilityContext = this.context;
windowStage.setUIContent(this.context, "pages/index", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] 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'
export default class MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility1 onCreate")
globalThis.abilityWant = want;
console.log("[Demo] MainAbility1 context: " + JSON.stringify(this.context));
var listKey1 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey1.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey1:" + JSON.stringify(listKey1));
},
onAbilityWindowStageCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityWindowStageCreate");
listKey1.push(abilityname + " onAbilityWindowStageCreate");
console.log("[Demo] 2listKey1:" + JSON.stringify(listKey1));
},
onAbilityWindowStageDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityWindowStageDestroy");
listKey1.push(abilityname + " onAbilityWindowStageDestroy");
console.log("[Demo] 3listKey1:" + JSON.stringify(listKey1));
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey1.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey1:" + JSON.stringify(listKey1));
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey1.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey1:" + JSON.stringify(listKey1));
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey1.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey1:" + JSON.stringify(listKey1));
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback1 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey1.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey1:" + JSON.stringify(listKey1));
}
}
let applicationContext = this.context.getApplicationContext();
console.log("[Demo] MainAbility1 applicationContext: " + JSON.stringify(applicationContext));
let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback1 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback1 listKey: " + JSON.stringify(listKey1));
globalThis.list1 = listKey1;
globalThis.callbackid1 = lifecycleid;
}, 2500);
}
onDestroy() {
console.log("[Demo] MainAbility1 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility1 onWindowStageCreate")
globalThis.ability1context = this.context;
windowStage.setUIContent(this.context, "pages/index1", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility1 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility1 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility1 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'
export default class MainAbility10 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility10 onCreate")
globalThis.abilityWant = want;
var listKey10 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey10.push(abilityname + " onAbilityCreate");
console.log("[Demo] 1listKey10:" + JSON.stringify(listKey10));
},
onAbilityWindowStageCreate(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityWindowStageCreate");
listKey10.push(abilityname + " onAbilityWindowStageCreate");
console.log("[Demo] 2listKey10:" + JSON.stringify(listKey10));
},
onAbilityWindowStageDestroy(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityWindowStageDestroy");
listKey10.push(abilityname + " onAbilityWindowStageDestroy");
console.log("[Demo] 3listKey10:" + JSON.stringify(listKey10));
},
onAbilityDestroy(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey10.push(abilityname + " onAbilityDestroy");
console.log("[Demo] 4listKey10:" + JSON.stringify(listKey10));
},
onAbilityForeground(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey10.push(abilityname + " onAbilityForeground");
console.log("[Demo] 5listKey10:" + JSON.stringify(listKey10));
},
onAbilityBackground(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey10.push(abilityname + " onAbilityBackground");
console.log("[Demo] 6listKey10:" + JSON.stringify(listKey10));
},
onAbilityContinue(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback10 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey10.push(abilityname + " onAbilityContinue");
console.log("[Demo] 7listKey10:" + JSON.stringify(listKey10));
}
}
let applicationContext = this.context.getApplicationContext();
console.log("[Demo] MainAbility10 applicationContext: " + JSON.stringify(applicationContext));
let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback10 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback10 listKey: " + JSON.stringify(listKey10));
globalThis.list10 = listKey10;
globalThis.callbackid10 = lifecycleid;
}, 1500);
}
onDestroy() {
console.log("[Demo] MainAbility10 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility10 onWindowStageCreate")
globalThis.ability10 = this.context;
windowStage.setUIContent(this.context, "pages/index10", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility10 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility10 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility10 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'
export default class MainAbility11 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility11 onCreate")
globalThis.abilityWant = want;
globalThis.ability11 = this.context;
var listKey11 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey11.push(abilityname + " onAbilityCreate");
},
onAbilityWindowStageCreate(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityWindowStageCreate abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityWindowStageCreate");
listKey11.push(abilityname + " onAbilityWindowStageCreate");
},
onAbilityWindowStageDestroy(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityWindowStageDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityWindowStageDestroy");
listKey11.push(abilityname + " onAbilityWindowStageDestroy");
},
onAbilityDestroy(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityDestroy abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey11.push(abilityname + " onAbilityDestroy");
},
onAbilityForeground(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityForeground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey11.push(abilityname + " onAbilityForeground");
},
onAbilityBackground(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityBackground abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey11.push(abilityname + " onAbilityBackground");
},
onAbilityContinue(ability) {
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] AbilityLifecycleCallback11 onAbilityContinue abilityname:"
+ JSON.stringify(abilityname));
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey11.push(abilityname + " onAbilityContinue");
}
}
let applicationContext = globalThis.ability11.getApplicationContext();
console.log("[Demo] MainAbility11 applicationContext: " + JSON.stringify(applicationContext));
let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback11 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback11 listKey: " + JSON.stringify(listKey11));
globalThis.list11 = listKey11;
globalThis.callbackid11 = lifecycleid;
}, 2000);
}
onDestroy() {
console.log("[Demo] MainAbility11 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility11 onWindowStageCreate")
windowStage.setUIContent(this.context, "pages/index11", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility11 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility11 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] 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'
export default class MainAbility12 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility12 onCreate")
globalThis.abilityWant = want;
var listKey12 = [];
let AbilityLifecycleCallback = {
onAbilityCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityCreate");
listKey12.push(abilityname + " onAbilityCreate");
},
onAbilityWindowStageCreate(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityWindowStageCreate ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityWindowStageCreate");
listKey12.push(abilityname + " onAbilityWindowStageCreate");
},
onAbilityWindowStageDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityWindowStageDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityWindowStageDestroy");
listKey12.push(abilityname + " onAbilityWindowStageDestroy");
},
onAbilityDestroy(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityDestroy ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityDestroy");
listKey12.push(abilityname + " onAbilityDestroy");
},
onAbilityForeground(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityForeground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityForeground");
listKey12.push(abilityname + " onAbilityForeground");
},
onAbilityBackground(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityBackground ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityBackground");
listKey12.push(abilityname + " onAbilityBackground");
},
onAbilityContinue(ability) {
console.log("[Demo] AbilityLifecycleCallback12 onAbilityContinue ability:"
+ JSON.stringify(ability));
let abilityname = ability.context.abilityInfo.name;
console.log("[Demo] " + abilityname + " onAbilityContinue");
listKey12.push(abilityname + " onAbilityContinue");
}
}
let applicationContext = this.context.getApplicationContext();
console.log("[Demo] MainAbility12 applicationContext: " + JSON.stringify(applicationContext));
let lifecycleid = applicationContext.registerAbilityLifecycleCallback(AbilityLifecycleCallback);
console.log("[Demo] registerAbilityLifecycleCallback12 number: " + JSON.stringify(lifecycleid));
setTimeout(function () {
console.log("[Demo] registerAbilityLifecycleCallback12 listKey: " + JSON.stringify(listKey12));
globalThis.list12 = listKey12;
globalThis.callbackid12 = lifecycleid;
}, 1700);
}
onDestroy() {
console.log("[Demo] MainAbility12 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility12 onWindowStageCreate")
globalThis.ability12 = this.context;
windowStage.setUIContent(this.context, "pages/index12", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility12 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility12 onForeground")
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility12 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'
export default class MainAbility2 extends Ability {
onCreate(want, launchParam) {
console.log("[Demo] MainAbility2 onCreate")
globalThis.abilityWant = want;
}
onDestroy() {
console.log("[Demo] MainAbility2 onDestroy")
}
onWindowStageCreate(windowStage) {
// Main window is created, set main page for this ability
console.log("[Demo] MainAbility2 onWindowStageCreate")
globalThis.ability2 = this.context;
windowStage.setUIContent(this.context, "pages/index2", null)
}
onWindowStageDestroy() {
// Main window is destroyed, release UI related resources
console.log("[Demo] MainAbility2 onWindowStageDestroy")
}
onForeground() {
// Ability has brought to foreground
console.log("[Demo] MainAbility2 onForeground")
setTimeout(function () {
globalThis.ability2.terminateSelf()
.then((data) => {
console.info('[Demo] MainAbility2 terminateself succeeded: ' + data);
}).catch((error) => {
console.error('[Demo] MainAbility2 terminateself failed. Cause: ' + error);
})
}, 500);
}
onBackground() {
// Ability has back to background
console.log("[Demo] MainAbility2 onBackground")
}
};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册