提交 87d549e9 编写于 作者: X xinking129

modify format

Signed-off-by: Nxinking129 <xinxin13@huawei.com>
上级 3f5ae173
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window'; import type Window from '@ohos.window';
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
let commonStateArr: number[] = [-1, -1, -1, -1]; let commonStateArr: number[] = [-1, -1, -1, -1];
...@@ -23,16 +23,18 @@ let commonEventData = { ...@@ -23,16 +23,18 @@ let commonEventData = {
commonStateArr: commonStateArr commonStateArr: commonStateArr
} }
}; };
let onForeGroundTAG = -1;
let TAG = 'StateChangeTestTAG'; let tag = 'StateChangeTesttag';
let delayTime_500 = 500; let delayTime_500 = 500;
let delayTime_1000 = 1000; let delayTime_1000 = 1000;
let delayTime_2000 = 2000; let delayTime_2000 = 2000;
let undefineTag = -1; let undefineTag = -1;
let defineTag = 1; let defineTag = 1;
let arrLength = 4;
let onForeGroundTAG = undefineTag;
let applicationStateChangeCallbackFir = { let applicationStateChangeCallbackFir = {
onApplicationForeground() { onApplicationForeground() {
console.log(TAG, 'applicationStateChangeCallbackFir onApplicationForeground'); console.log(tag, 'applicationStateChangeCallbackFir onApplicationForeground');
commonEventData.parameters.commonStateArr[0] = defineTag; commonEventData.parameters.commonStateArr[0] = defineTag;
setTimeout(() => { setTimeout(() => {
...@@ -43,7 +45,7 @@ let applicationStateChangeCallbackFir = { ...@@ -43,7 +45,7 @@ let applicationStateChangeCallbackFir = {
}, delayTime_1000); }, delayTime_1000);
}, },
onApplicationBackground() { onApplicationBackground() {
console.log(TAG, 'applicationStateChangeCallbackFir onApplicationBackground'); console.log(tag, 'applicationStateChangeCallbackFir onApplicationBackground');
commonEventData.parameters.commonStateArr[1] = defineTag; commonEventData.parameters.commonStateArr[1] = defineTag;
if (globalThis.want.action === 'NeedBackGroundOff' || globalThis.want.action === 'MultiAppRegister') { if (globalThis.want.action === 'NeedBackGroundOff' || globalThis.want.action === 'MultiAppRegister') {
...@@ -55,11 +57,11 @@ let applicationStateChangeCallbackFir = { ...@@ -55,11 +57,11 @@ let applicationStateChangeCallbackFir = {
let applicationStateChangeCallbackSec = { let applicationStateChangeCallbackSec = {
onApplicationForeground() { onApplicationForeground() {
console.log(TAG, 'applicationStateChangeCallbackSec onApplicationForeground'); console.log(tag, 'applicationStateChangeCallbackSec onApplicationForeground');
commonEventData.parameters.commonStateArr[2] = defineTag; commonEventData.parameters.commonStateArr[2] = defineTag;
}, },
onApplicationBackground() { onApplicationBackground() {
console.log(TAG, 'applicationStateChangeCallbackSec onApplicationBackground'); console.log(tag, 'applicationStateChangeCallbackSec onApplicationBackground');
commonEventData.parameters.commonStateArr[3] = defineTag; commonEventData.parameters.commonStateArr[3] = defineTag;
if (globalThis.want.action === 'doubleNeedBackGroundOff') { if (globalThis.want.action === 'doubleNeedBackGroundOff') {
setTimeout(() => { setTimeout(() => {
...@@ -78,7 +80,7 @@ let applicationStateChangeCallbackSec = { ...@@ -78,7 +80,7 @@ let applicationStateChangeCallbackSec = {
export default class EntryAbility extends Ability { export default class EntryAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
onForeGroundTAG = undefineTag; onForeGroundTAG = undefineTag;
for (let i = 0; i < 4; i++) { for (let i = 0; i < arrLength; i++) {
commonStateArr[i] = undefineTag; commonStateArr[i] = undefineTag;
} }
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
...@@ -93,7 +95,7 @@ export default class EntryAbility extends Ability { ...@@ -93,7 +95,7 @@ export default class EntryAbility extends Ability {
globalThis.applicationContext.off('applicationStateChange', applicationStateChangeCallbackFir); globalThis.applicationContext.off('applicationStateChange', applicationStateChangeCallbackFir);
} }
globalThis.applicationContext.on('applicationStateChange', applicationStateChangeCallbackFir); globalThis.applicationContext.on('applicationStateChange', applicationStateChangeCallbackFir);
if (globalThis.want.action === 'doubleRegister' || globalThis.want.action === 'doubleNeedBackGroundOff'|| if (globalThis.want.action === 'doubleRegister' || globalThis.want.action === 'doubleNeedBackGroundOff' ||
globalThis.want.action === 'DoubleRegisterOff') { globalThis.want.action === 'DoubleRegisterOff') {
console.info('double in action is logic entered!'); console.info('double in action is logic entered!');
globalThis.applicationContext.on('applicationStateChange', applicationStateChangeCallbackSec); globalThis.applicationContext.on('applicationStateChange', applicationStateChangeCallbackSec);
...@@ -132,8 +134,8 @@ export default class EntryAbility extends Ability { ...@@ -132,8 +134,8 @@ export default class EntryAbility extends Ability {
// Ability has brought to foreground // Ability has brought to foreground
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Abilityone onForeground'); hilog.info(0x0000, 'testTag', '%{public}s', 'Abilityone onForeground');
onForeGroundTAG += 1; onForeGroundTAG += defineTag;
if (onForeGroundTAG === 1 && (globalThis.want.action === 'NeedBackGroundOff' || globalThis.want.action === 'MultiAppRegister'|| if (onForeGroundTAG === defineTag && (globalThis.want.action === 'NeedBackGroundOff' || globalThis.want.action === 'MultiAppRegister' ||
globalThis.want.action === 'DoubleRegisterOff')) { globalThis.want.action === 'DoubleRegisterOff')) {
setTimeout(() => { setTimeout(() => {
commonEvent.publish('processState', commonEventData, (err) => { commonEvent.publish('processState', commonEventData, (err) => {
......
...@@ -18,10 +18,12 @@ import type Window from '@ohos.window'; ...@@ -18,10 +18,12 @@ import type Window from '@ohos.window';
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
let TAG = 'getRunningProcess'; let tag = 'getRunningProcess';
let commonStateArr; let commonStateArr;
let delayTime_3000 = 3000; let delayTime_3000 = 3000;
let delayTime_1000 = 1000; let delayTime_1000 = 1000;
let undefinedTag = -1;
let definedTag = 1;
let commonEventData = { let commonEventData = {
parameters: { parameters: {
commonStateArr: commonStateArr commonStateArr: commonStateArr
...@@ -29,10 +31,10 @@ let commonEventData = { ...@@ -29,10 +31,10 @@ let commonEventData = {
}; };
let applicationStateChangeCallbackFir = { let applicationStateChangeCallbackFir = {
onApplicationForeground() { onApplicationForeground() {
console.log(TAG, 'applicationStateChangeCallbackFir onApplicationForeground'); console.log(tag, 'applicationStateChangeCallbackFir onApplicationForeground');
}, },
onApplicationBackground() { onApplicationBackground() {
console.log(TAG, 'applicationStateChangeCallbackFir onApplicationBackground'); console.log(tag, 'applicationStateChangeCallbackFir onApplicationBackground');
setTimeout(() => { setTimeout(() => {
console.info('Enter onApplicationForeground publish!'); console.info('Enter onApplicationForeground publish!');
commonEventData.parameters.commonStateArr = 1; commonEventData.parameters.commonStateArr = 1;
...@@ -42,12 +44,12 @@ let applicationStateChangeCallbackFir = { ...@@ -42,12 +44,12 @@ let applicationStateChangeCallbackFir = {
}, delayTime_1000); }, delayTime_1000);
} }
}; };
let foregroundTAG = -1; let foregroundTAG = undefinedTag;
export default class EntryAbility extends Ability { export default class EntryAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
foregroundTAG = -1; foregroundTAG = undefinedTag;
commonEventData.parameters.commonStateArr = -1; commonEventData.parameters.commonStateArr = undefinedTag;
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); 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', 'want param:' + JSON.stringify(want) ?? '');
...@@ -89,7 +91,7 @@ export default class EntryAbility extends Ability { ...@@ -89,7 +91,7 @@ export default class EntryAbility extends Ability {
onForeground() { onForeground() {
// Ability has brought to foreground // Ability has brought to foreground
foregroundTAG++; foregroundTAG++;
if (foregroundTAG === 1) { if (foregroundTAG === definedTag) {
setTimeout(() => { setTimeout(() => {
commonEvent.publish('processState', commonEventData, (err) => { commonEvent.publish('processState', commonEventData, (err) => {
console.info('====>processState publish err: ' + JSON.stringify(err)); console.info('====>processState publish err: ' + JSON.stringify(err));
......
...@@ -14,8 +14,9 @@ ...@@ -14,8 +14,9 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window'; import type Window from '@ohos.window';
let delayTime_3000 = 3000;
export default class EntryAbility1 extends Ability { export default class EntryAbility1 extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
...@@ -62,7 +63,7 @@ export default class EntryAbility1 extends Ability { ...@@ -62,7 +63,7 @@ export default class EntryAbility1 extends Ability {
globalThis.abilityContext2.terminateSelf((err) => { globalThis.abilityContext2.terminateSelf((err) => {
console.log('terminateSelf result:' + JSON.stringify(err)); console.log('terminateSelf result:' + JSON.stringify(err));
}); });
}, 3000); }, delayTime_3000);
} }
onBackground() { onBackground() {
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window'; import type Window from '@ohos.window';
let TAG = 'StateChangeTestTAG'; let TAG = 'StateChangeTestTAG';
let delayTime_3000 = 3000; let delayTime_3000 = 3000;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window'; import type Window from '@ohos.window';
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import AbilityConstant from '@ohos.app.ability.AbilityConstant'; import AbilityConstant from '@ohos.app.ability.AbilityConstant';
......
...@@ -16,8 +16,8 @@ import hilog from '@ohos.hilog'; ...@@ -16,8 +16,8 @@ import hilog from '@ohos.hilog';
import TestRunner from '@ohos.application.testRunner' import TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined let abilityDelegator = undefined
var abilityDelegatorArguments = undefined let abilityDelegatorArguments = undefined
function translateParamsToString(parameters) { function translateParamsToString(parameters) {
const keySet = new Set([ const keySet = new Set([
...@@ -58,15 +58,15 @@ export default class OpenHarmonyTestRunner implements TestRunner { ...@@ -58,15 +58,15 @@ export default class OpenHarmonyTestRunner implements TestRunner {
hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run');
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility'; let testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility';
let lMonitor = { let lMonitor = {
abilityName: testAbilityName, abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback, onAbilityCreate: onAbilityCreateCallback,
}; };
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName; let cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName;
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters['-D']; let debug = abilityDelegatorArguments.parameters['-D'];
if (debug == 'true') { if (debug == 'true') {
cmd += ' -D' cmd += ' -D'
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
*/ */
import hilog from '@ohos.hilog'; import hilog from '@ohos.hilog';
import Ability from '@ohos.app.ability.UIAbility'; import Ability from '@ohos.app.ability.UIAbility';
import Window from '@ohos.window'; import type Window from '@ohos.window';
export default class EntryAbility extends Ability { export default class EntryAbility extends Ability {
onCreate(want, launchParam) { onCreate(want, launchParam) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册