Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
2c001841
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2c001841
编写于
7月 17, 2023
作者:
X
xinking129
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code check
Signed-off-by:
N
xinking129
<
xinxin13@huawei.com
>
上级
536b6e6e
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
418 addition
and
415 deletion
+418
-415
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeOneReply/entry/src/main/ets/entryability/EntryAbility.ts
...eOneReply/entry/src/main/ets/entryability/EntryAbility.ts
+114
-113
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeThreeReply/entry/src/main/ets/entryability/EntryAbility.ts
...hreeReply/entry/src/main/ets/entryability/EntryAbility.ts
+81
-79
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeThreeReply/entry/src/main/ets/entryability1/EntryAbility1.ts
...eeReply/entry/src/main/ets/entryability1/EntryAbility1.ts
+49
-49
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
...eTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
+61
-61
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationOneReply/entry/src/main/ets/entryability/EntryAbility.ts
...nOneReply/entry/src/main/ets/entryability/EntryAbility.ts
+19
-19
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+53
-53
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
...nTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
+41
-41
未找到文件。
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeOneReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
2c001841
...
...
@@ -13,87 +13,89 @@
* limitations under the License.
*/
import
hilog
from
'
@ohos.hilog
'
;
import
Ability
from
'
@ohos.app.ability.UIAbility
'
import
Window
from
'
@ohos.window
'
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
import
type
Window
from
'
@ohos.window
'
;
import
commonEvent
from
'
@ohos.commonEvent
'
;
let
commonStateArr
:
number
[]
=
[
-
1
,
-
1
,
-
1
,
-
1
]
const
ONE_SECOND
=
1000
;
const
FIVE_HUNDRED_MILLISECOND
=
500
;
const
VALID_STATE
=
1
;
const
INVALID_STATE
=
-
1
;
const
TAG
=
'
StateChangeTestTAG
'
;
let
commonStateArr
:
number
[]
=
[
-
1
,
-
1
,
-
1
,
-
1
];
let
commonEventData
=
{
parameters
:
{
commonStateArr
:
commonStateArr
}
}
let
onForeGroundTAG
=
-
1
let
TAG
=
'
StateChangeTestTAG
'
let
ApplicationStateChangeCallbackFir
=
{
};
let
onForeGroundTAG
=
INVALID_STATE
;
let
applicationStateChangeCallbackFir
=
{
onApplicationForeground
()
{
console
.
log
(
TAG
,
'
ApplicationStateChangeCallbackFir onApplicationForeground
'
)
commonEventData
.
parameters
.
commonStateArr
[
0
]
=
1
console
.
log
(
TAG
,
'
applicationStateChangeCallbackFir onApplicationForeground
'
);
commonEventData
.
parameters
.
commonStateArr
[
0
]
=
VALID_STATE
;
setTimeout
(()
=>
{
console
.
info
(
'
Enter onApplicationForeground publish!
'
)
console
.
info
(
'
Enter onApplicationForeground publish!
'
);
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
"
====>processState publish err:
"
+
JSON
.
stringify
(
err
))
})
},
1000
)
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
});
},
ONE_SECOND
);
},
onApplicationBackground
()
{
console
.
log
(
TAG
,
'
ApplicationStateChangeCallbackFir onApplicationBackground
'
)
commonEventData
.
parameters
.
commonStateArr
[
1
]
=
1
console
.
log
(
TAG
,
'
applicationStateChangeCallbackFir onApplicationBackground
'
);
commonEventData
.
parameters
.
commonStateArr
[
1
]
=
VALID_STATE
;
if
(
globalThis
.
want
.
action
==
'
NeedBackGroundOff
'
||
globalThis
.
want
.
action
==
'
MultiAppRegister
'
||
globalThis
.
want
.
action
==
'
DoubleRegisterOff
'
)
{
console
.
info
(
'
entered needbackgroundoff!
'
)
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
,
ApplicationStateChangeCallbackFir
)
if
(
globalThis
.
want
.
action
===
'
NeedBackGroundOff
'
||
globalThis
.
want
.
action
===
'
MultiAppRegister
'
||
globalThis
.
want
.
action
=
==
'
DoubleRegisterOff
'
)
{
console
.
info
(
'
entered needbackgroundoff!
'
);
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
,
applicationStateChangeCallbackFir
);
}
}
}
}
;
let
A
pplicationStateChangeCallbackSec
=
{
let
a
pplicationStateChangeCallbackSec
=
{
onApplicationForeground
()
{
console
.
log
(
TAG
,
'
ApplicationStateChangeCallbackSec onApplicationForeground
'
)
commonEventData
.
parameters
.
commonStateArr
[
2
]
=
1
console
.
log
(
TAG
,
'
applicationStateChangeCallbackSec onApplicationForeground
'
);
commonEventData
.
parameters
.
commonStateArr
[
2
]
=
VALID_STATE
;
},
onApplicationBackground
()
{
console
.
log
(
TAG
,
'
ApplicationStateChangeCallbackSec onApplicationBackground
'
)
commonEventData
.
parameters
.
commonStateArr
[
3
]
=
1
if
(
globalThis
.
want
.
action
==
'
doubleNeedBackGroundOff
'
)
{
console
.
log
(
TAG
,
'
applicationStateChangeCallbackSec onApplicationBackground
'
);
commonEventData
.
parameters
.
commonStateArr
[
3
]
=
VALID_STATE
;
if
(
globalThis
.
want
.
action
=
==
'
doubleNeedBackGroundOff
'
)
{
setTimeout
(()
=>
{
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
,
ApplicationStateChangeCallbackSec
)
},
500
)
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
,
applicationStateChangeCallbackSec
);
},
FIVE_HUNDRED_MILLISECOND
);
}
else
if
(
globalThis
.
want
.
action
==
'
DoubleRegisterOff
'
)
{
else
if
(
globalThis
.
want
.
action
=
==
'
DoubleRegisterOff
'
)
{
setTimeout
(()
=>
{
console
.
info
(
'
entered DoubleRegisterOff
'
)
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
)
},
500
)
console
.
info
(
'
entered DoubleRegisterOff
'
);
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
);
},
FIVE_HUNDRED_MILLISECOND
);
}
}
}
export
default
class
EntryAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
onForeGroundTAG
=
-
1
onForeGroundTAG
=
INVALID_STATE
;
for
(
let
i
=
0
;
i
<
4
;
i
++
)
{
commonStateArr
[
i
]
=
-
1
commonStateArr
[
i
]
=
INVALID_STATE
;
}
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
.
abilityContext
=
this
.
context
globalThis
.
want
=
want
globalThis
.
abilityContext
=
this
.
context
;
globalThis
.
want
=
want
;
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
if
(
globalThis
.
want
.
action
==
'
RegisterOnOffOn
'
)
{
globalThis
.
applicationContext
.
on
(
'
applicationStateChange
'
,
ApplicationStateChangeCallbackFir
)
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
,
ApplicationStateChangeCallbackFir
)
if
(
globalThis
.
want
.
action
=
==
'
RegisterOnOffOn
'
)
{
globalThis
.
applicationContext
.
on
(
'
applicationStateChange
'
,
applicationStateChangeCallbackFir
);
globalThis
.
applicationContext
.
off
(
'
applicationStateChange
'
,
applicationStateChangeCallbackFir
);
}
globalThis
.
applicationContext
.
on
(
'
applicationStateChange
'
,
ApplicationStateChangeCallbackFir
)
if
(
globalThis
.
want
.
action
==
'
doubleRegister
'
||
globalThis
.
want
.
action
==
'
doubleNeedBackGroundOff
'
||
globalThis
.
want
.
action
==
'
DoubleRegisterOff
'
)
{
console
.
info
(
"
double in action is logic entered!
"
)
globalThis
.
applicationContext
.
on
(
'
applicationStateChange
'
,
ApplicationStateChangeCallbackSec
)
globalThis
.
applicationContext
.
on
(
'
applicationStateChange
'
,
applicationStateChangeCallbackFir
);
if
(
globalThis
.
want
.
action
===
'
doubleRegister
'
||
globalThis
.
want
.
action
=
==
'
doubleNeedBackGroundOff
'
||
globalThis
.
want
.
action
=
==
'
DoubleRegisterOff
'
)
{
console
.
info
(
'
double in action is logic entered!
'
);
globalThis
.
applicationContext
.
on
(
'
applicationStateChange
'
,
applicationStateChangeCallbackSec
);
}
}
onDestroy
()
{
...
...
@@ -127,15 +129,14 @@ export default class EntryAbility extends Ability {
// Ability has brought to foreground
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Abilityone onForeground
'
);
onForeGroundTAG
+=
1
if
(
onForeGroundTAG
==
1
&&
(
globalThis
.
want
.
action
==
'
NeedBackGroundOff
'
||
globalThis
.
want
.
action
==
'
MultiAppRegister
'
||
globalThis
.
want
.
action
==
'
DoubleRegisterOff
'
))
{
onForeGroundTAG
++
;
if
(
onForeGroundTAG
===
VALID_STATE
&&
(
globalThis
.
want
.
action
===
'
NeedBackGroundOff
'
||
globalThis
.
want
.
action
=
==
'
MultiAppRegister
'
||
globalThis
.
want
.
action
=
==
'
DoubleRegisterOff
'
))
{
setTimeout
(()
=>
{
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
"
====>processState publish err:
"
+
JSON
.
stringify
(
err
))
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
})
},
2000
)
},
2000
);
}
}
...
...
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeThreeReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
2c001841
...
...
@@ -13,47 +13,49 @@
* limitations under the License.
*/
import
hilog
from
'
@ohos.hilog
'
;
import
Ability
from
'
@ohos.app.ability.UIAbility
'
import
Window
from
'
@ohos.window
'
import
commonEvent
from
'
@ohos.commonEvent
'
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
import
type
Window
from
'
@ohos.window
'
;
import
commonEvent
from
'
@ohos.commonEvent
'
;
let
TAG
=
'
getRunningProcess
'
let
commonStateArr
const
ONE_SECOND
=
1000
;
const
THREE_SECOND
=
3000
;
const
VALID_STATE
=
1
;
const
INVALID_STATE
=
-
1
;
const
TAG
=
'
getRunningProcess
'
;
let
commonStateArr
;
let
commonEventData
=
{
parameters
:
{
commonStateArr
:
commonStateArr
}
}
let
A
pplicationStateChangeCallbackFir
=
{
}
;
let
a
pplicationStateChangeCallbackFir
=
{
onApplicationForeground
()
{
console
.
log
(
TAG
,
'
ApplicationStateChangeCallbackFir onApplicationForeground
'
)
console
.
log
(
TAG
,
'
applicationStateChangeCallbackFir onApplicationForeground
'
);
},
onApplicationBackground
()
{
console
.
log
(
TAG
,
'
ApplicationStateChangeCallbackFir onApplicationBackground
'
)
console
.
log
(
TAG
,
'
applicationStateChangeCallbackFir onApplicationBackground
'
);
setTimeout
(()
=>
{
console
.
info
(
'
Enter onApplicationForeground publish!
'
)
commonEventData
.
parameters
.
commonStateArr
=
1
console
.
info
(
'
Enter onApplicationForeground publish!
'
);
commonEventData
.
parameters
.
commonStateArr
=
VALID_STATE
;
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
"
====>processState publish err:
"
+
JSON
.
stringify
(
err
))
})
},
1000
)
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
});
},
ONE_SECOND
);
}
}
let
ForegroundTAG
=
-
1
}
;
let
foregroundTAG
=
INVALID_STATE
;
export
default
class
EntryAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
ForegroundTAG
=
-
1
commonEventData
.
parameters
.
commonStateArr
=
-
1
foregroundTAG
=
INVALID_STATE
;
commonEventData
.
parameters
.
commonStateArr
=
INVALID_STATE
;
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
.
abilityContext1
=
this
.
context
globalThis
.
want1
=
want
globalThis
.
abilityContext1
=
this
.
context
;
globalThis
.
want1
=
want
;
globalThis
.
applicationContext1
=
this
.
context
.
getApplicationContext
();
globalThis
.
applicationContext1
.
on
(
'
applicationStateChange
'
,
ApplicationStateChangeCallbackFir
)
globalThis
.
applicationContext1
.
on
(
'
applicationStateChange
'
,
applicationStateChangeCallbackFir
);
}
onDestroy
()
{
...
...
@@ -85,13 +87,13 @@ export default class EntryAbility extends Ability {
onForeground
()
{
// Ability has brought to foreground
F
oregroundTAG
++
if
(
ForegroundTAG
==
1
)
{
f
oregroundTAG
++
if
(
foregroundTAG
===
VALID_STATE
)
{
setTimeout
(()
=>
{
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
"
====>processState publish err:
"
+
JSON
.
stringify
(
err
))
console
.
info
(
'
====>processState publish err:
'
+
JSON
.
stringify
(
err
));
})
},
3000
)
},
THREE_SECOND
)
}
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
...
...
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeThreeReply/entry/src/main/ets/entryability1/EntryAbility1.ts
浏览文件 @
2c001841
...
...
@@ -13,8 +13,8 @@
* limitations under the License.
*/
import
hilog
from
'
@ohos.hilog
'
;
import
Ability
from
'
@ohos.app.ability.UIAbility
'
import
Window
from
'
@ohos.window
'
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
import
type
Window
from
'
@ohos.window
'
;
export
default
class
EntryAbility1
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
...
...
@@ -22,8 +22,8 @@ export default class EntryAbility1 extends Ability {
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
.
abilityContext2
=
this
.
context
globalThis
.
want2
=
want
globalThis
.
abilityContext2
=
this
.
context
;
globalThis
.
want2
=
want
;
globalThis
.
applicationContext2
=
this
.
context
.
getApplicationContext
();
}
...
...
@@ -61,8 +61,8 @@ export default class EntryAbility1 extends Ability {
setTimeout
(()
=>
{
globalThis
.
abilityContext2
.
terminateSelf
((
err
)
=>
{
console
.
log
(
'
terminateSelf result:
'
+
JSON
.
stringify
(
err
));
})
},
3000
)
});
},
3000
);
}
onBackground
()
{
...
...
ability/ability_runtime/getrunningprocessinformation/ApplicationStateChangeTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
2c001841
...
...
@@ -13,18 +13,18 @@
* limitations under the License.
*/
import
hilog
from
'
@ohos.hilog
'
;
import
Ability
from
'
@ohos.app.ability.UIAbility
'
import
Window
from
'
@ohos.window
'
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
import
type
Window
from
'
@ohos.window
'
;
let
TAG
=
'
StateChangeTestTAG
'
let
A
pplicationStateChangeCallbackSec
=
{
const
TAG
=
'
StateChangeTestTAG
'
;
let
a
pplicationStateChangeCallbackSec
=
{
onApplicationForeground
()
{
console
.
info
(
'
==== ApplicationStateChange Foreground ====
'
);
console
.
log
(
TAG
,
'
App2 ApplicationStateChangeCallbackSec onApplicationForeground
'
)
console
.
log
(
TAG
,
'
App2 applicationStateChangeCallbackSec onApplicationForeground
'
);
},
onApplicationBackground
()
{
console
.
info
(
'
==== ApplicationStateChange Background ====
'
);
console
.
log
(
TAG
,
'
App2 ApplicationStateChangeCallbackSec onApplicationBackground
'
)
console
.
log
(
TAG
,
'
App2 applicationStateChangeCallbackSec onApplicationBackground
'
);
}
}
export
default
class
EntryAbility
extends
Ability
{
...
...
@@ -34,11 +34,11 @@ export default class EntryAbility extends Ability {
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
want param:
'
+
JSON
.
stringify
(
want
)
??
''
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
launchParam:
'
+
JSON
.
stringify
(
launchParam
)
??
''
);
globalThis
.
abilityContext
=
this
.
context
globalThis
.
want
=
want
if
(
want
.
action
==
'
MultiAppRegister
'
||
want
.
action
==
'
DoubleRegisterOff
'
)
{
globalThis
.
abilityContext
=
this
.
context
;
globalThis
.
want
=
want
;
if
(
want
.
action
===
'
MultiAppRegister
'
||
want
.
action
=
==
'
DoubleRegisterOff
'
)
{
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
globalThis
.
applicationContext
.
on
(
'
applicationStateChange
'
,
ApplicationStateChangeCallbackSec
)
globalThis
.
applicationContext
.
on
(
'
applicationStateChange
'
,
applicationStateChangeCallbackSec
);
}
}
...
...
@@ -76,8 +76,8 @@ export default class EntryAbility extends Ability {
setTimeout
(()
=>
{
globalThis
.
abilityContext
.
terminateSelf
((
err
)
=>
{
console
.
log
(
'
terminateSelf result:
'
+
JSON
.
stringify
(
err
));
})
},
3000
)
});
},
3000
);
}
onBackground
()
{
...
...
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationOneReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
2c001841
...
...
@@ -13,19 +13,19 @@
* limitations under the License.
*/
import
hilog
from
'
@ohos.hilog
'
;
import
Ability
from
'
@ohos.app.ability.UIAbility
'
import
Window
from
'
@ohos.window
'
import
commonEvent
from
'
@ohos.commonEvent
'
import
AbilityConstant
from
'
@ohos.app.ability.AbilityConstant
'
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
import
type
Window
from
'
@ohos.window
'
;
import
commonEvent
from
'
@ohos.commonEvent
'
;
import
AbilityConstant
from
'
@ohos.app.ability.AbilityConstant
'
;
let
sequence
=
0
;
let
TAG
=
'
GetRunningProcessInformation
'
let
commonStateArr
:
number
[]
=
[
-
1
,
-
1
,
-
1
,
-
1
]
let
TAG
=
'
GetRunningProcessInformation
'
;
let
commonStateArr
:
number
[]
=
[
-
1
,
-
1
,
-
1
,
-
1
]
;
let
commonEventData
=
{
parameters
:
{
commonStateArr
:
commonStateArr
}
}
}
;
globalThis
.
StartFloatingAbility
=
()
=>
{
let
want
=
{
"
deviceId
"
:
""
,
...
...
@@ -36,8 +36,8 @@ globalThis.StartFloatingAbility = () => {
windowMode
:
AbilityConstant
.
WindowMode
.
WINDOW_MODE_FLOATING
,
};
globalThis
.
abilityContext
.
startAbility
(
want
,
options
,
(
error
)
=>
{
console
.
log
(
TAG
,
"
start floating ability error.code =
"
+
error
.
code
)
})
console
.
log
(
TAG
,
"
start floating ability error.code =
"
+
error
.
code
)
;
})
;
}
globalThis
.
StartNormalAbility
=
()
=>
{
...
...
@@ -47,8 +47,8 @@ globalThis.StartNormalAbility = () => {
"
abilityName
"
:
"
EntryAbility
"
};
globalThis
.
abilityContext
.
startAbility
(
want
,
(
error
)
=>
{
console
.
log
(
TAG
,
"
start normal ability error.code =
"
+
error
.
code
)
})
console
.
log
(
TAG
,
"
start normal ability error.code =
"
+
error
.
code
)
;
})
;
}
globalThis
.
GetRunningProcessInfoCallback
=
()
=>
{
...
...
@@ -58,15 +58,15 @@ globalThis.GetRunningProcessInfoCallback = () => {
}
else
{
console
.
log
(
TAG
,
'
Oncreate Callback State:
'
+
JSON
.
stringify
(
data
[
0
].
state
));
commonStateArr
[
sequence
++
]
=
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
commonStateArr
[
sequence
++
]
=
data
[
0
].
state
;
}).
catch
((
err
)
=>
{
console
.
log
(
TAG
,
`getRunningProcessInformation err: `
+
JSON
.
stringify
(
err
));
});
...
...
@@ -74,20 +74,20 @@ globalThis.GetRunningProcessInfoPromise = () => {
globalThis
.
PublishStateArray
=
()
=>
{
commonEvent
.
publish
(
'
processState
'
,
commonEventData
,
(
err
)
=>
{
console
.
info
(
"
====>processState publish err:
"
+
JSON
.
stringify
(
err
))
})
console
.
info
(
"
====>processState publish err:
"
+
JSON
.
stringify
(
err
))
;
})
;
}
export
default
class
EntryAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
sequence
=
0
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
.
want
=
want
;
globalThis
.
abilityContext
=
this
.
context
;
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
}
...
...
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationTest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
浏览文件 @
2c001841
...
...
@@ -13,25 +13,25 @@
* limitations under the License.
*/
import
hilog
from
'
@ohos.hilog
'
;
import
TestRunner
from
'
@ohos.application.testRunner
'
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
import
TestRunner
from
'
@ohos.application.testRunner
'
;
import
AbilityDelegatorRegistry
from
'
@ohos.application.abilityDelegatorRegistry
'
;
var
abilityDelegator
=
undefined
var
abilityDelegatorArguments
=
undefined
let
abilityDelegator
=
undefined
;
let
abilityDelegatorArguments
=
undefined
;
function
translateParamsToString
(
parameters
)
{
const
keySet
=
new
Set
([
'
-s class
'
,
'
-s notClass
'
,
'
-s suite
'
,
'
-s it
'
,
'
-s level
'
,
'
-s testType
'
,
'
-s size
'
,
'
-s timeout
'
,
'
-s dryRun
'
])
]);
let
targetParams
=
''
;
for
(
const
key
in
parameters
)
{
if
(
keySet
.
has
(
key
))
{
targetParams
=
`
${
targetParams
}
${
key
}
${
parameters
[
key
]}
`
targetParams
=
`
${
targetParams
}
${
key
}
${
parameters
[
key
]}
`
;
}
}
return
targetParams
.
trim
()
return
targetParams
.
trim
();
}
async
function
onAbilityCreateCallback
()
{
...
...
@@ -56,20 +56,20 @@ export default class OpenHarmonyTestRunner implements TestRunner {
async
onRun
()
{
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
OpenHarmonyTestRunner onRun run
'
);
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.TestAbility
'
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
();
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
();
let
testAbilityName
=
abilityDelegatorArguments
.
bundleName
+
'
.TestAbility
'
;
let
lMonitor
=
{
abilityName
:
testAbilityName
,
onAbilityCreate
:
onAbilityCreateCallback
,
};
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
)
var
cmd
=
'
aa start -d 0 -a TestAbility
'
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
)
var
debug
=
abilityDelegatorArguments
.
parameters
[
'
-D
'
]
abilityDelegator
.
addAbilityMonitor
(
lMonitor
,
addAbilityMonitorCallback
);
let
cmd
=
'
aa start -d 0 -a TestAbility
'
+
'
-b
'
+
abilityDelegatorArguments
.
bundleName
;
cmd
+=
'
'
+
translateParamsToString
(
abilityDelegatorArguments
.
parameters
);
let
debug
=
abilityDelegatorArguments
.
parameters
[
'
-D
'
];
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
cmd
+=
'
-D
'
;
}
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
cmd : %{public}s
'
,
cmd
);
...
...
@@ -79,7 +79,7 @@ export default class OpenHarmonyTestRunner implements TestRunner {
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
executeShellCommand : err : %{public}s
'
,
JSON
.
stringify
(
err
)
??
''
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
executeShellCommand : data : %{public}s
'
,
d
.
stdResult
??
''
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
executeShellCommand : data : %{public}s
'
,
d
.
exitCode
??
''
);
})
});
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
OpenHarmonyTestRunner onRun end
'
);
}
}
\ No newline at end of file
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationTwoReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
2c001841
...
...
@@ -13,8 +13,8 @@
* limitations under the License.
*/
import
hilog
from
'
@ohos.hilog
'
;
import
Ability
from
'
@ohos.app.ability.UIAbility
'
import
Window
from
'
@ohos.window
'
import
Ability
from
'
@ohos.app.ability.UIAbility
'
;
import
type
Window
from
'
@ohos.window
'
;
export
default
class
EntryAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录