diff --git a/ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationOneReply/entry/src/main/ets/entryability/EntryAbility.ts b/ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationOneReply/entry/src/main/ets/entryability/EntryAbility.ts index 9e866a0f1d937615c7ec010bb6c04f2d2fe743fe..d778a5aeae272bbec89c1a356f8e12f5649b4f41 100644 --- a/ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationOneReply/entry/src/main/ets/entryability/EntryAbility.ts +++ b/ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationOneReply/entry/src/main/ets/entryability/EntryAbility.ts @@ -22,111 +22,111 @@ let sequence = 0; let TAG = 'GetRunningProcessInformation' let commonStateArr: number[] = [-1, -1, -1, -1] let commonEventData = { - parameters: { - commonStateArr: commonStateArr - } + parameters: { + commonStateArr: commonStateArr + } } globalThis.StartFloatingAbility = () => { - let want = { - "deviceId": "", - "bundleName": "com.example.getrunningprocessinformationtworeply", // - "abilityName": "EntryAbility" - }; - let options = { - windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING, - }; - globalThis.abilityContext.startAbility(want, options, (error) => { - console.log(TAG, "start floating ability error.code = " + error.code) - }) + let want = { + "deviceId": "", + "bundleName": "com.example.getrunningprocessinformationtworeply", // + "abilityName": "EntryAbility" + }; + let options = { + windowMode: AbilityConstant.WindowMode.WINDOW_MODE_FLOATING, + }; + globalThis.abilityContext.startAbility(want, options, (error) => { + console.log(TAG, "start floating ability error.code = " + error.code) + }) } globalThis.StartNormalAbility = () => { - let want = { - "deviceId": "", - "bundleName": "com.example.getrunningprocessinformationtworeply", // - "abilityName": "EntryAbility" - }; - globalThis.abilityContext.startAbility(want, (error) => { - console.log(TAG, "start normal ability error.code = " + error.code) - }) + let want = { + "deviceId": "", + "bundleName": "com.example.getrunningprocessinformationtworeply", // + "abilityName": "EntryAbility" + }; + globalThis.abilityContext.startAbility(want, (error) => { + console.log(TAG, "start normal ability error.code = " + error.code) + }) } globalThis.GetRunningProcessInfoCallback = () => { - globalThis.applicationContext.getRunningProcessInformation((err, data) => { - if (err) { - console.log(TAG, `getRunningProcessInformation err: ` + JSON.stringify(err)); - } - else { - console.log(TAG, 'Oncreate Callback State: ' + JSON.stringify(data[0].state)); - commonStateArr[sequence++] = data[0].state - } - }) + globalThis.applicationContext.getRunningProcessInformation((err, data) => { + if (err) { + console.log(TAG, `getRunningProcessInformation err: ` + JSON.stringify(err)); + } + else { + console.log(TAG, 'Oncreate Callback State: ' + JSON.stringify(data[0].state)); + commonStateArr[sequence++] = data[0].state + } + }) } globalThis.GetRunningProcessInfoPromise = () => { - globalThis.applicationContext.getRunningProcessInformation().then((data) => { - console.log(TAG, 'Oncreate Promise State: ' + JSON.stringify(data[0].state)); - commonStateArr[sequence++] = data[0].state - }).catch((err) => { - console.log(TAG, `getRunningProcessInformation err: ` + JSON.stringify(err)); - }); + globalThis.applicationContext.getRunningProcessInformation().then((data) => { + console.log(TAG, 'Oncreate Promise State: ' + JSON.stringify(data[0].state)); + commonStateArr[sequence++] = data[0].state + }).catch((err) => { + console.log(TAG, `getRunningProcessInformation err: ` + JSON.stringify(err)); + }); } globalThis.PublishStateArray = () => { - commonEvent.publish('processState', commonEventData, (err) => { - console.info("====>processState publish err: " + JSON.stringify(err)) - }) + commonEvent.publish('processState', commonEventData, (err) => { + console.info("====>processState publish err: " + JSON.stringify(err)) + }) } export default class EntryAbility extends Ability { - onCreate(want, launchParam) { - sequence = 0 - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); - hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); - hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); + onCreate(want, launchParam) { + sequence = 0 + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? ''); - globalThis.want = want - globalThis.abilityContext = this.context - globalThis.applicationContext = this.context.getApplicationContext(); + globalThis.want = want + globalThis.abilityContext = this.context + globalThis.applicationContext = this.context.getApplicationContext(); - } + } - onDestroy() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); - } - onWindowStageCreate(windowStage: Window.WindowStage) { - // Main window is created, set main page for this ability - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + onDestroy() { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + onWindowStageCreate(windowStage: Window.WindowStage) { + // Main window is created, set main page for this ability + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/Index', (err, data) => { - if (err.code) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); - }); - } + windowStage.loadContent('pages/Index', (err, data) => { + if (err.code) { + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); + }); + } - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); - } + onWindowStageDestroy() { + // Main window is destroyed, release UI related resources + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } - onForeground() { - // Ability has brought to foreground - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); - } + onForeground() { + // Ability has brought to foreground + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } - onBackground() { - // Ability has back to background - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); - } + onBackground() { + // Ability has back to background + hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } }