diff --git a/ability/ability_runtime/actsuiextensiontest/BUILD.gn b/ability/ability_runtime/actsuiextensiontest/BUILD.gn index d1fc806cacd39dd6a380c5eb5c946fc6426b66d6..77fc6b05761a2cdae3ae86e98a6a60fc73c4a771 100644 --- a/ability/ability_runtime/actsuiextensiontest/BUILD.gn +++ b/ability/ability_runtime/actsuiextensiontest/BUILD.gn @@ -17,9 +17,9 @@ group("actsuiextensiontest") { testonly = true if (is_standard_system) { deps = [ + "actsabilityusertest:StartAbilityByUIContentSession", "uiextensionprovider:UIExtensionProvider", "uiextensiontest:UIExtensionTest", - "actsabilityusertest:StartAbilityByUIContentSession", ] } } diff --git a/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility/MainAbility.ts b/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility/MainAbility.ts index 79ba798ea1b4c0f98704caae53e1342fa62445b8..05ee7a22854a5a3bd2b438ea9287287e570dfdb0 100644 --- a/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility/MainAbility.ts +++ b/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility/MainAbility.ts @@ -15,28 +15,29 @@ import Ability from '@ohos.app.ability.UIAbility' export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log('MainAbility onCreate') - } - onDestroy() { - console.log('MainAbility onDestroy') - } + onCreate(want, launchParam) { + console.log('MainAbility onCreate'); + } - onWindowStageCreate(windowStage) { - console.log('MainAbility onWindowStageCreate') - windowStage.setUIContent(this.context, 'MainAbility/pages/index', null) - } + onDestroy() { + console.log('MainAbility onDestroy'); + } - onWindowStageDestroy() { - console.log('MainAbility onWindowStageDestroy') - } + onWindowStageCreate(windowStage) { + console.log('MainAbility onWindowStageCreate'); + windowStage.setUIContent(this.context, 'MainAbility/pages/index', null); + } - onForeground() { - console.log('MainAbility onForeground') - } + onWindowStageDestroy() { + console.log('MainAbility onWindowStageDestroy'); + } - onBackground() { - console.log('MainAbility onBackground') - } + onForeground() { + console.log('MainAbility onForeground'); + } + + onBackground() { + console.log('MainAbility onBackground'); + } }; \ No newline at end of file diff --git a/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility2/MainAbility2.ts b/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility2/MainAbility2.ts index 206293c0631e8fe3585c484c6e4b93c89a3b1575..fe36c2a15f00661343f63ffb19d067dc25e47ac5 100644 --- a/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility2/MainAbility2.ts +++ b/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility2/MainAbility2.ts @@ -12,60 +12,62 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import Ability from '@ohos.app.ability.UIAbility' -import commonEventManager from '@ohos.commonEventManager' +import Ability from '@ohos.app.ability.UIAbility'; +import commonEventManager from '@ohos.commonEventManager'; -function PublishCallBackOne() { - console.log("====>Publish CallBack ACTS_StartAbility_0100_CommonEvent====>"); - globalThis.ability2Context.terminateSelf().then(()=>{ - console.log("====>terminateSelf success====>"); - }); +const sleepTimeOne = 1000; + +function publishCallBack() { + console.log('====>Publish CallBack ACTS_StartAbility_0100_CommonEvent====>'); + globalThis.ability2Context.terminateSelf().then(()=>{ + console.log('====>terminateSelf success====>'); + }); } function timeout() { - globalThis.ability2Context.startAbility( + globalThis.ability2Context.startAbility( { - bundleName: 'com.example.uiextensiontest', - abilityName: 'TestAbility', + bundleName: 'com.example.uiextensiontest', + abilityName: 'TestAbility', } - ).then(()=>{ - console.log("====>start com.example.uiextensiontest.TestAbility finish====>") - }); - } + ).then(()=>{ + console.log('====>start com.example.uiextensiontest.TestAbility finish====>'); + }); +} export default class MainAbility2 extends Ability { - onCreate(want, launchParam) { - console.log("MainAbility2 onCreate"); - } + onCreate(want, launchParam) { + console.log('MainAbility2 onCreate'); + } - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("MainAbility2 onDestroy"); - } + onDestroy() { + // Ability is destroying, release resources for this ability + console.log('MainAbility2 onDestroy'); + } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("MainAbility2 onWindowStageCreate"); - windowStage.setUIContent(this.context, "pages/index2", null); - } + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log('MainAbility2 onWindowStageCreate'); + windowStage.setUIContent(this.context, 'pages/index2', null); + } - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("MainAbility2 onWindowStageDestroy"); - } + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log('MainAbility2 onWindowStageDestroy'); + } - onForeground() { - // Ability has brought to foreground - console.log("MainAbility2 onForeground"); - globalThis.ability2Context = this.context; - setTimeout(timeout, 1000); - } + onForeground() { + // Ability has brought to foreground + console.log('MainAbility2 onForeground'); + globalThis.ability2Context = this.context; + setTimeout(timeout, sleepTimeOne); + } - onBackground() { - // Ability has back to background - console.log("MainAbility2 onBackground"); - let onResultEvent = 'ACTS_UIExtension_StartAbility_OnResult'; - commonEventManager.publish(onResultEvent, PublishCallBackOne); - } + onBackground() { + // Ability has back to background + console.log('MainAbility2 onBackground'); + let onResultEvent = 'ACTS_UIExtension_StartAbility_OnResult'; + commonEventManager.publish(onResultEvent, publishCallBack); + } }; diff --git a/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility3/MainAbility3.ts b/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility3/MainAbility3.ts index 28df4e28da0e5e7d0fdff739bf6084de5eab69df..115b51e2100d75cf6d4589ddbec2e12f6805bfcd 100644 --- a/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility3/MainAbility3.ts +++ b/ability/ability_runtime/actsuiextensiontest/actsabilityusertest/entry/src/main/ets/MainAbility3/MainAbility3.ts @@ -12,60 +12,61 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import Ability from '@ohos.app.ability.UIAbility' +import Ability from '@ohos.app.ability.UIAbility'; + +const sleepTimeOne = 1000; function timeout() { - globalThis.ability3Context.startAbility( + globalThis.ability3Context.startAbility( { - bundleName: 'com.example.uiextensiontest', - abilityName: 'TestAbility', + bundleName: 'com.example.uiextensiontest', + abilityName: 'TestAbility' } - ).then(()=>{ - console.log("====>start com.example.uiextensiontest.TestAbility finish====>") - }); - } + ).then(()=>{ + console.log('====>start com.example.uiextensiontest.TestAbility finish====>'); + }); +} export default class MainAbility3 extends Ability { - onCreate(want, launchParam) { - console.log("MainAbility3 onCreate"); - } + onCreate(want, launchParam) { + console.log('MainAbility3 onCreate'); + } - onDestroy() { - // Ability is destroying, release resources for this ability - console.log("MainAbility3 onDestroy"); - } + onDestroy() { + // Ability is destroying, release resources for this ability + console.log('MainAbility3 onDestroy'); + } - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("MainAbility3 onWindowStageCreate"); - windowStage.setUIContent(this.context, "pages/index3", null); - } + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log('MainAbility3 onWindowStageCreate'); + windowStage.setUIContent(this.context, 'pages/index3', null); + } - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("MainAbility3 onWindowStageDestroy"); - } + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + console.log('MainAbility3 onWindowStageDestroy'); + } - onForeground() { - // Ability has brought to foreground - console.log("MainAbility3 onForeground"); - globalThis.ability3Context = this.context; - setTimeout(timeout, 1000); - - } + onForeground() { + // Ability has brought to foreground + console.log('MainAbility3 onForeground'); + globalThis.ability3Context = this.context; + setTimeout(timeout, sleepTimeOne); + } - onBackground() { - // Ability has back to background - console.log("MainAbility3 onBackground"); - globalThis.ability3Context.terminateSelfWithResult( - { - resultCode:1, - want:{ - action:'ACTION' + onBackground() { + // Ability has back to background + console.log('MainAbility3 onBackground'); + globalThis.ability3Context.terminateSelfWithResult( + { + resultCode:1, + want:{ + action:'ACTION' } - },()=>{ - console.debug("====>terminateSelfWithResult success====>") - }); - } + }, ()=>{ + console.debug('====>terminateSelfWithResult success====>'); + }); + } };