Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
8b5c5bc9
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看板
提交
8b5c5bc9
编写于
7月 17, 2023
作者:
X
xinking129
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify code
Signed-off-by:
N
xinking129
<
xinxin13@huawei.com
>
上级
6079f60d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
83 addition
and
83 deletion
+83
-83
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationOneReply/entry/src/main/ets/entryability/EntryAbility.ts
...nOneReply/entry/src/main/ets/entryability/EntryAbility.ts
+83
-83
未找到文件。
ability/ability_runtime/getrunningprocessinformation/GetRunningProcessInformationOneReply/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
8b5c5bc9
...
@@ -22,111 +22,111 @@ let sequence = 0;
...
@@ -22,111 +22,111 @@ let sequence = 0;
let
TAG
=
'
GetRunningProcessInformation
'
let
TAG
=
'
GetRunningProcessInformation
'
let
commonStateArr
:
number
[]
=
[
-
1
,
-
1
,
-
1
,
-
1
]
let
commonStateArr
:
number
[]
=
[
-
1
,
-
1
,
-
1
,
-
1
]
let
commonEventData
=
{
let
commonEventData
=
{
parameters
:
{
parameters
:
{
commonStateArr
:
commonStateArr
commonStateArr
:
commonStateArr
}
}
}
}
globalThis
.
StartFloatingAbility
=
()
=>
{
globalThis
.
StartFloatingAbility
=
()
=>
{
let
want
=
{
let
want
=
{
"
deviceId
"
:
""
,
"
deviceId
"
:
""
,
"
bundleName
"
:
"
com.example.getrunningprocessinformationtworeply
"
,
//
"
bundleName
"
:
"
com.example.getrunningprocessinformationtworeply
"
,
//
"
abilityName
"
:
"
EntryAbility
"
"
abilityName
"
:
"
EntryAbility
"
};
};
let
options
=
{
let
options
=
{
windowMode
:
AbilityConstant
.
WindowMode
.
WINDOW_MODE_FLOATING
,
windowMode
:
AbilityConstant
.
WindowMode
.
WINDOW_MODE_FLOATING
,
};
};
globalThis
.
abilityContext
.
startAbility
(
want
,
options
,
(
error
)
=>
{
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
=
()
=>
{
globalThis
.
StartNormalAbility
=
()
=>
{
let
want
=
{
let
want
=
{
"
deviceId
"
:
""
,
"
deviceId
"
:
""
,
"
bundleName
"
:
"
com.example.getrunningprocessinformationtworeply
"
,
//
"
bundleName
"
:
"
com.example.getrunningprocessinformationtworeply
"
,
//
"
abilityName
"
:
"
EntryAbility
"
"
abilityName
"
:
"
EntryAbility
"
};
};
globalThis
.
abilityContext
.
startAbility
(
want
,
(
error
)
=>
{
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
=
()
=>
{
globalThis
.
GetRunningProcessInfoCallback
=
()
=>
{
globalThis
.
applicationContext
.
getRunningProcessInformation
((
err
,
data
)
=>
{
globalThis
.
applicationContext
.
getRunningProcessInformation
((
err
,
data
)
=>
{
if
(
err
)
{
if
(
err
)
{
console
.
log
(
TAG
,
`getRunningProcessInformation err: `
+
JSON
.
stringify
(
err
));
console
.
log
(
TAG
,
`getRunningProcessInformation err: `
+
JSON
.
stringify
(
err
));
}
}
else
{
else
{
console
.
log
(
TAG
,
'
Oncreate Callback State:
'
+
JSON
.
stringify
(
data
[
0
].
state
));
console
.
log
(
TAG
,
'
Oncreate Callback State:
'
+
JSON
.
stringify
(
data
[
0
].
state
));
commonStateArr
[
sequence
++
]
=
data
[
0
].
state
commonStateArr
[
sequence
++
]
=
data
[
0
].
state
}
}
})
})
}
}
globalThis
.
GetRunningProcessInfoPromise
=
()
=>
{
globalThis
.
GetRunningProcessInfoPromise
=
()
=>
{
globalThis
.
applicationContext
.
getRunningProcessInformation
().
then
((
data
)
=>
{
globalThis
.
applicationContext
.
getRunningProcessInformation
().
then
((
data
)
=>
{
console
.
log
(
TAG
,
'
Oncreate Promise State:
'
+
JSON
.
stringify
(
data
[
0
].
state
));
console
.
log
(
TAG
,
'
Oncreate Promise State:
'
+
JSON
.
stringify
(
data
[
0
].
state
));
commonStateArr
[
sequence
++
]
=
data
[
0
].
state
commonStateArr
[
sequence
++
]
=
data
[
0
].
state
}).
catch
((
err
)
=>
{
}).
catch
((
err
)
=>
{
console
.
log
(
TAG
,
`getRunningProcessInformation err: `
+
JSON
.
stringify
(
err
));
console
.
log
(
TAG
,
`getRunningProcessInformation err: `
+
JSON
.
stringify
(
err
));
});
});
}
}
globalThis
.
PublishStateArray
=
()
=>
{
globalThis
.
PublishStateArray
=
()
=>
{
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
))
})
})
}
}
export
default
class
EntryAbility
extends
Ability
{
export
default
class
EntryAbility
extends
Ability
{
onCreate
(
want
,
launchParam
)
{
onCreate
(
want
,
launchParam
)
{
sequence
=
0
sequence
=
0
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
)
??
''
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
launchParam:
'
+
JSON
.
stringify
(
launchParam
)
??
''
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
launchParam:
'
+
JSON
.
stringify
(
launchParam
)
??
''
);
globalThis
.
want
=
want
globalThis
.
want
=
want
globalThis
.
abilityContext
=
this
.
context
globalThis
.
abilityContext
=
this
.
context
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
globalThis
.
applicationContext
=
this
.
context
.
getApplicationContext
();
}
}
onDestroy
()
{
onDestroy
()
{
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onDestroy
'
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onDestroy
'
);
}
}
onWindowStageCreate
(
windowStage
:
Window
.
WindowStage
)
{
onWindowStageCreate
(
windowStage
:
Window
.
WindowStage
)
{
// Main window is created, set main page for this ability
// Main window is created, set main page for this ability
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onWindowStageCreate
'
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onWindowStageCreate
'
);
windowStage
.
loadContent
(
'
pages/Index
'
,
(
err
,
data
)
=>
{
windowStage
.
loadContent
(
'
pages/Index
'
,
(
err
,
data
)
=>
{
if
(
err
.
code
)
{
if
(
err
.
code
)
{
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
ERROR
);
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
ERROR
);
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
Failed to load the content. Cause: %{public}s
'
,
JSON
.
stringify
(
err
)
??
''
);
hilog
.
error
(
0x0000
,
'
testTag
'
,
'
Failed to load the content. Cause: %{public}s
'
,
JSON
.
stringify
(
err
)
??
''
);
return
;
return
;
}
}
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
Succeeded in loading the content. Data: %{public}s
'
,
JSON
.
stringify
(
data
)
??
''
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
Succeeded in loading the content. Data: %{public}s
'
,
JSON
.
stringify
(
data
)
??
''
);
});
});
}
}
onWindowStageDestroy
()
{
onWindowStageDestroy
()
{
// Main window is destroyed, release UI related resources
// Main window is destroyed, release UI related resources
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onWindowStageDestroy
'
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onWindowStageDestroy
'
);
}
}
onForeground
()
{
onForeground
()
{
// 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
'
,
'
Ability onForeground
'
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onForeground
'
);
}
}
onBackground
()
{
onBackground
()
{
// Ability has back to background
// Ability has back to background
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
isLoggable
(
0x0000
,
'
testTag
'
,
hilog
.
LogLevel
.
INFO
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onBackground
'
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onBackground
'
);
}
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录