Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
6bdeb4ff
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看板
提交
6bdeb4ff
编写于
7月 20, 2023
作者:
X
xinking129
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
changeCodeCheck
Signed-off-by:
N
xinking129
<
xinxin13@huawei.com
>
上级
9aae33a4
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
258 addition
and
255 deletion
+258
-255
ability/ability_runtime/actsforresult/forresulttest/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
...est/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
+40
-39
ability/ability_runtime/actsforresult/forresulttest/entry/src/main/ets/calledability/CalledAbility.ts
...ulttest/entry/src/main/ets/calledability/CalledAbility.ts
+3
-3
ability/ability_runtime/actsforresult/forresulttest/entry/src/main/ets/entryability/EntryAbility.ts
...esulttest/entry/src/main/ets/entryability/EntryAbility.ts
+9
-9
ability/ability_runtime/actsforresult/forresulttestnopermission/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
...ion/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
+35
-34
ability/ability_runtime/actsforresult/forresulttestnopermission/entry/src/main/ets/calledability/CalledAbility.ts
...mission/entry/src/main/ets/calledability/CalledAbility.ts
+1
-1
ability/ability_runtime/actsforresult/forresulttestnopermission/entry/src/main/ets/entryability/EntryAbility.ts
...ermission/entry/src/main/ets/entryability/EntryAbility.ts
+13
-13
ability/ability_runtime/actsforresult/main/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
...ain/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
+78
-77
ability/ability_runtime/actsforresult/main/entry/src/main/ets/calledability/CalledAbility.ts
...lt/main/entry/src/main/ets/calledability/CalledAbility.ts
+9
-9
ability/ability_runtime/actsforresult/main/entry/src/main/ets/entryability/EntryAbility.ts
...sult/main/entry/src/main/ets/entryability/EntryAbility.ts
+25
-24
ability/ability_runtime/actsforresult/main/entry/src/main/ets/otherability/OtherAbility.ts
...sult/main/entry/src/main/ets/otherability/OtherAbility.ts
+15
-15
ability/ability_runtime/actsforresult/maintest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
...st/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
+30
-31
未找到文件。
ability/ability_runtime/actsforresult/forresulttest/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -12,22 +12,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
UIExtensionAbility
from
'
@ohos.app.ability.UIExtensionAbility
'
import
UIExtensionAbility
from
'
@ohos.app.ability.UIExtensionAbility
'
;
import
wantConstant
from
'
@ohos.app.ability.wantConstant
'
;
import
commonEvent
from
'
@ohos.commonEventManager
'
import
commonEvent
from
'
@ohos.commonEventManager
'
;
import
hilog
from
'
@ohos.hilog
'
;
export
default
class
U
I
ExtAbility
extends
UIExtensionAbility
{
export
default
class
U
i
ExtAbility
extends
UIExtensionAbility
{
onCreate
()
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
UIExtAbility onCreate want: %{public}s
'
);
console
.
info
(
'
=======>UIExtAbility onCreate======>
'
);
}
onSessionCreate
(
want
,
session
)
{
console
.
log
(
`want:
${
JSON
.
stringify
(
want
)}
}`
)
console
.
log
(
`want:
${
JSON
.
stringify
(
want
)}
}`
)
;
let
storage
:
LocalStorage
=
new
LocalStorage
({
'
session
'
:
session
});
session
.
loadContent
(
'
pages/Page
'
,
storage
)
session
.
loadContent
(
'
pages/Page
'
,
storage
)
;
console
.
info
(
'
=======>UIExtAbility onSessionCreate======>
'
);
if
(
want
.
action
===
'
AsyncCallback_0200
'
)
{
...
...
@@ -44,7 +45,7 @@ export default class UIExtAbility extends UIExtensionAbility {
console
.
info
(
'
=======>Callback_0200 first from another data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Callback_0200 first from another data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
parameters
:
{
num
:
error
.
code
,
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
...
...
@@ -52,8 +53,8 @@ export default class UIExtAbility extends UIExtensionAbility {
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0200 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
})
;
})
;
}
if
(
want
.
action
===
'
AsyncCallback_0300
'
)
{
...
...
@@ -70,16 +71,16 @@ export default class UIExtAbility extends UIExtensionAbility {
console
.
info
(
'
=======>Callback_0300 first from another data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Callback_0300 first from another data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
parameters
:
{
num
:
error
.
code
,
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}
}
;
commonEvent
.
publish
(
'
ACTS_CALL_EVENT_ANOTHER
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0300 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
})
;
})
;
}
if
(
want
.
action
===
'
Promise_0200
'
)
{
...
...
@@ -91,21 +92,21 @@ export default class UIExtAbility extends UIExtensionAbility {
parameters
:
{
[
wantConstant
.
Params
.
ABILITY_BACK_TO_OTHER_MISSION_STACK
]:
true
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0200 first from another data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0200 first from another data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0200 first from another data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0200 first from another data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:
{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0200 first publish err:
'
+
JSON
.
stringify
(
err
));
})
}).
catch
((
error
)
=>
{
};
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0200 first publish err:
'
+
JSON
.
stringify
(
err
));
});
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0200 first from another error.code ======>
'
+
error
.
code
);
})
})
;
}
if
(
want
.
action
===
'
Promise_0300
'
)
{
...
...
@@ -117,26 +118,26 @@ export default class UIExtAbility extends UIExtensionAbility {
parameters
:
{
[
wantConstant
.
Params
.
ABILITY_BACK_TO_OTHER_MISSION_STACK
]:
true
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0300 first from another data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0300 first from another data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0300 first from another data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0300 first from another data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:
{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT_ANOTHER
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0300 first publish err:
'
+
JSON
.
stringify
(
err
));
})
}).
catch
((
error
)
=>
{
};
commonEvent
.
publish
(
'
ACTS_CALL_EVENT_ANOTHER
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0300 first publish err:
'
+
JSON
.
stringify
(
err
));
});
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0300 first from another error.code ======>
'
+
error
.
code
);
})
})
;
}
}
onSessionDestroy
(
session
)
{
console
.
log
(
`onSessionDestroy`
)
console
.
log
(
'
onSessionDestroy
'
);
}
onDestroy
()
{
...
...
ability/ability_runtime/actsforresult/forresulttest/entry/src/main/ets/calledability/CalledAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -14,7 +14,7 @@
*/
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
hilog
from
'
@ohos.hilog
'
;
import
window
from
'
@ohos.window
'
;
import
type
window
from
'
@ohos.window
'
;
export
default
class
CalledAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
...
...
@@ -22,7 +22,7 @@ export default class CalledAbility extends UIAbility {
console
.
log
(
'
=====> second app CalledAbility bas been created =====>
'
);
if
(
want
.
action
==
'
AsyncCallback_0200
'
)
{
if
(
want
.
action
==
=
'
AsyncCallback_0200
'
)
{
this
.
context
.
terminateSelfWithResult
({
resultCode
:
0
,
want
:
{
...
...
@@ -32,7 +32,7 @@ export default class CalledAbility extends UIAbility {
}
},
(
err
)
=>
{
console
.
log
(
'
=====> AsyncCallback_0200 CalledAbilityCallBack terminateSelfWithResult =====>
'
+
err
.
code
);
})
})
;
}
}
...
...
ability/ability_runtime/actsforresult/forresulttest/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -19,38 +19,38 @@ import window from '@ohos.window';
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onCreate
'
);
console
.
info
(
"
====>another EntryAbility
"
);
console
.
info
(
'
====>another EntryAbility
'
);
if
(
want
.
action
==
'
AsyncCallback_0200
'
)
{
if
(
want
.
action
=
==
'
AsyncCallback_0200
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0200':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0200
"
,
action
:
'
AsyncCallback_0200
'
,
bundleName
:
'
com.example.forresulttestsecond
'
,
abilityName
:
'
UIExtAbility
'
});
}
if
(
want
.
action
==
'
AsyncCallback_0300
'
)
{
if
(
want
.
action
=
==
'
AsyncCallback_0300
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0300':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0300
"
,
action
:
'
AsyncCallback_0300
'
,
bundleName
:
'
com.example.forresulttestsecond
'
,
abilityName
:
'
UIExtAbility
'
});
}
if
(
want
.
action
==
'
Promise_0200
'
)
{
if
(
want
.
action
=
==
'
Promise_0200
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'Promise_0200':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
Promise_0200
"
,
action
:
'
Promise_0200
'
,
bundleName
:
'
com.example.forresulttestsecond
'
,
abilityName
:
'
UIExtAbility
'
});
}
if
(
want
.
action
==
'
Promise_0300
'
)
{
if
(
want
.
action
=
==
'
Promise_0300
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'Promise_0300':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
Promise_0300
"
,
action
:
'
Promise_0300
'
,
bundleName
:
'
com.example.forresulttestsecond
'
,
abilityName
:
'
UIExtAbility
'
});
...
...
ability/ability_runtime/actsforresult/forresulttestnopermission/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -12,22 +12,23 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
UIExtensionAbility
from
'
@ohos.app.ability.UIExtensionAbility
'
import
UIExtensionAbility
from
'
@ohos.app.ability.UIExtensionAbility
'
;
import
wantConstant
from
'
@ohos.app.ability.wantConstant
'
;
import
commonEvent
from
'
@ohos.commonEventManager
'
import
commonEvent
from
'
@ohos.commonEventManager
'
;
import
hilog
from
'
@ohos.hilog
'
;
export
default
class
U
I
ExtAbility
extends
UIExtensionAbility
{
export
default
class
U
i
ExtAbility
extends
UIExtensionAbility
{
onCreate
()
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
UIExtAbility onCreate want: %{public}s
'
);
console
.
info
(
'
=======>UIExtAbility onCreate======>
'
);
}
onSessionCreate
(
want
,
session
)
{
console
.
log
(
`want:
${
JSON
.
stringify
(
want
)}
}`
)
console
.
log
(
`want:
${
JSON
.
stringify
(
want
)}
}`
)
;
let
storage
:
LocalStorage
=
new
LocalStorage
({
'
session
'
:
session
});
session
.
loadContent
(
'
pages/Page
'
,
storage
)
session
.
loadContent
(
'
pages/Page
'
,
storage
)
;
console
.
info
(
'
=======>UIExtAbility onSessionCreate======>
'
);
if
(
want
.
action
===
'
AsyncCallback_0600
'
)
{
...
...
@@ -42,14 +43,14 @@ export default class UIExtAbility extends UIExtensionAbility {
},
(
error
,
data
)
=>
{
console
.
info
(
'
=======>Callback_0600 first from own error.code ======>
'
+
error
.
code
);
let
commonEventData
=
{
parameters
:{
parameters
:
{
num
:
error
.
code
}
}
}
;
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0600 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
})
;
})
;
}
if
(
want
.
action
===
'
AsyncCallback_0700
'
)
{
...
...
@@ -64,14 +65,14 @@ export default class UIExtAbility extends UIExtensionAbility {
},
(
error
,
data
)
=>
{
console
.
info
(
'
=======>Callback_0700 first from own error.code ======>
'
+
error
.
code
);
let
commonEventData
=
{
parameters
:{
parameters
:
{
num
:
error
.
code
}
}
}
;
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0700 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
})
;
})
;
}
if
(
want
.
action
===
'
Promise_0600
'
)
{
...
...
@@ -83,19 +84,19 @@ export default class UIExtAbility extends UIExtensionAbility {
parameters
:
{
[
wantConstant
.
Params
.
ABILITY_BACK_TO_OTHER_MISSION_STACK
]:
true
}
}).
then
((
data
)
=>
{
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0600 startAbilityForResult ok ======>
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0600 first from own error.code ======>
'
+
error
.
code
);
let
commonEventData
=
{
parameters
:{
num
:
error
.
code
}
let
commonEventData
=
{
parameters
:
{
num
:
error
.
code
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0600 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
};
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0600 first publish err:
'
+
JSON
.
stringify
(
err
));
});
});
}
if
(
want
.
action
===
'
Promise_0700
'
)
{
...
...
@@ -107,24 +108,24 @@ export default class UIExtAbility extends UIExtensionAbility {
parameters
:
{
[
wantConstant
.
Params
.
ABILITY_BACK_TO_OTHER_MISSION_STACK
]:
true
}
}).
then
((
data
)
=>
{
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0700 startAbilityForResult ok ======>
'
);
}).
catch
((
error
)
=>
{
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0700 first from own error.code ======>
'
+
error
.
code
);
let
commonEventData
=
{
parameters
:{
num
:
error
.
code
}
let
commonEventData
=
{
parameters
:
{
num
:
error
.
code
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0700 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
};
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0700 first publish err:
'
+
JSON
.
stringify
(
err
));
});
});
}
}
onSessionDestroy
(
session
)
{
console
.
log
(
`onSessionDestroy`
)
console
.
log
(
'
onSessionDestroy
'
);
}
onDestroy
()
{
...
...
ability/ability_runtime/actsforresult/forresulttestnopermission/entry/src/main/ets/calledability/CalledAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -14,7 +14,7 @@
*/
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
hilog
from
'
@ohos.hilog
'
;
import
window
from
'
@ohos.window
'
;
import
type
window
from
'
@ohos.window
'
;
export
default
class
CalledAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
...
...
ability/ability_runtime/actsforresult/forresulttestnopermission/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -19,39 +19,39 @@ import window from '@ohos.window';
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onCreate
'
);
console
.
info
(
"
====>another EntryAbility
"
);
console
.
info
(
'
====>another EntryAbility
'
);
if
(
want
.
action
==
'
AsyncCallback_0600
'
)
{
if
(
want
.
action
=
==
'
AsyncCallback_0600
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0600':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0600
"
,
action
:
'
AsyncCallback_0600
'
,
bundleName
:
'
com.example.forresulttestthrid
'
,
abilityName
:
'
UIExtAbility
'
});
}
if
(
want
.
action
==
'
AsyncCallback_0700
'
)
{
if
(
want
.
action
=
==
'
AsyncCallback_0700
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0700':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0700
"
,
action
:
'
AsyncCallback_0700
'
,
bundleName
:
'
com.example.forresulttestthrid
'
,
abilityName
:
'
UIExtAbility
'
});
}
if
(
want
.
action
==
'
Promise_0600
'
)
{
if
(
want
.
action
=
==
'
Promise_0600
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'Promise_0600':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
Promise_0600
"
,
action
:
'
Promise_0600
'
,
bundleName
:
'
com.example.forresulttestthrid
'
,
abilityName
:
'
UIExtAbility
'
});
}
if
(
want
.
action
==
'
Promise_0700
'
)
{
if
(
want
.
action
=
==
'
Promise_0700
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'Promise_0700':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
Promise_0700
"
,
action
:
'
Promise_0700
'
,
bundleName
:
'
com.example.forresulttestthrid
'
,
abilityName
:
'
UIExtAbility
'
});
...
...
@@ -84,19 +84,19 @@ export default class EntryAbility extends UIAbility {
// Ability has brought to foreground
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onForeground
'
);
if
(
want
.
action
==
'
AsyncCallback_0200
'
)
{
if
(
want
.
action
=
==
'
AsyncCallback_0200
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0200':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0200
"
,
action
:
'
AsyncCallback_0200
'
,
bundleName
:
'
com.example.forresulttestsecond
'
,
abilityName
:
'
UIExtAbility
'
});
}
if
(
want
.
action
==
'
AsyncCallback_0300
'
)
{
if
(
want
.
action
=
==
'
AsyncCallback_0300
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0300':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0300
"
,
action
:
'
AsyncCallback_0300
'
,
bundleName
:
'
com.example.forresulttestsecond
'
,
abilityName
:
'
UIExtAbility
'
});
...
...
ability/ability_runtime/actsforresult/main/entry/src/main/ets/UIExtensionAbility/UIExtAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -12,27 +12,28 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
UIExtensionAbility
from
'
@ohos.app.ability.UIExtensionAbility
'
import
UIExtensionAbility
from
'
@ohos.app.ability.UIExtensionAbility
'
;
import
wantConstant
from
'
@ohos.app.ability.wantConstant
'
;
import
commonEvent
from
'
@ohos.commonEventManager
'
import
commonEvent
from
'
@ohos.commonEventManager
'
;
// import Logger from '../model/Logger'
import
hilog
from
'
@ohos.hilog
'
;
// const TAG: string = '[UIExtensionAbility]'
export
default
class
U
I
ExtAbility
extends
UIExtensionAbility
{
export
default
class
U
i
ExtAbility
extends
UIExtensionAbility
{
onCreate
()
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
UIExtAbility onCreate want: %{public}s
'
);
console
.
info
(
'
=======>UIExtAbility onCreate======>
'
);
}
onSessionCreate
(
want
,
session
)
{
console
.
log
(
`want:
${
JSON
.
stringify
(
want
)}
}`
)
console
.
log
(
`want:
${
JSON
.
stringify
(
want
)}
}`
)
;
let
storage
:
LocalStorage
=
new
LocalStorage
({
'
session
'
:
session
});
session
.
loadContent
(
'
pages/Page
'
,
storage
)
session
.
loadContent
(
'
pages/Page
'
,
storage
)
;
console
.
info
(
'
=======>UIExtAbility onSessionCreate======>
'
);
if
(
want
.
action
==
'
AsyncCallback_0100
'
)
{
if
(
want
.
action
==
=
'
AsyncCallback_0100
'
)
{
console
.
info
(
'
=======>UIExtAbility onSessionCreate want.action == AsyncCallback_0100======>
'
);
this
.
context
.
startAbilityForResult
({
action
:
'
AsyncCallback_0100
'
,
...
...
@@ -46,16 +47,16 @@ export default class UIExtAbility extends UIExtensionAbility {
console
.
info
(
'
=======>Callback_0100 data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Callback_0100 data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
parameters
:
{
num
:
error
.
code
,
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}
}
;
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0100 publish err:
'
+
JSON
.
stringify
(
err
));
})
})
})
;
})
;
}
if
(
want
.
action
===
'
AsyncCallback_0300
'
)
{
...
...
@@ -72,16 +73,16 @@ export default class UIExtAbility extends UIExtensionAbility {
console
.
info
(
'
=======>Callback_0300 first from own data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Callback_0300 first from own data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
parameters
:
{
num
:
error
.
code
,
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}
}
;
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0300 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
})
;
})
;
}
if
(
want
.
action
===
'
AsyncCallback_0400
'
)
{
...
...
@@ -98,16 +99,16 @@ export default class UIExtAbility extends UIExtensionAbility {
console
.
info
(
'
=======>Callback_0400 first from own data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Callback_0400 first from own data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
parameters
:
{
num
:
error
.
code
,
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}
}
;
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0400 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
})
;
})
;
}
if
(
want
.
action
===
'
AsyncCallback_0500
'
)
{
...
...
@@ -122,17 +123,17 @@ export default class UIExtAbility extends UIExtensionAbility {
},
(
error
,
data
)
=>
{
console
.
info
(
'
=======>Callback_0500 first from own error.code ======>
'
+
error
.
code
);
let
commonEventData
=
{
parameters
:{
parameters
:
{
num
:
error
.
code
}
}
}
;
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0500 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
})
;
})
;
}
if
(
want
.
action
==
'
Promise_0100
'
)
{
if
(
want
.
action
==
=
'
Promise_0100
'
)
{
console
.
info
(
'
=======>UIExtAbility onSessionCreate want.action == Promise_0100======>
'
);
this
.
context
.
startAbilityForResult
({
action
:
'
Promise_0100
'
,
...
...
@@ -141,21 +142,21 @@ export default class UIExtAbility extends UIExtensionAbility {
parameters
:
{
[
wantConstant
.
Params
.
ABILITY_BACK_TO_OTHER_MISSION_STACK
]:
true
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0100 data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0100 data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0100 data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0100 data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:
{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0100 publish err:
'
+
JSON
.
stringify
(
err
));
})
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0100 error.code ======>
'
+
error
.
code
);
})
};
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0100 publish err:
'
+
JSON
.
stringify
(
err
));
});
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0100 error.code ======>
'
+
error
.
code
);
});
}
if
(
want
.
action
===
'
Promise_0300
'
)
{
...
...
@@ -167,21 +168,21 @@ export default class UIExtAbility extends UIExtensionAbility {
parameters
:
{
[
wantConstant
.
Params
.
ABILITY_BACK_TO_OTHER_MISSION_STACK
]:
true
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0300 first from own data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0300 first from own data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0300 first from own data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0300 first from own data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:
{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0300 first publish err:
'
+
JSON
.
stringify
(
err
));
})
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0300 first from own error.code ======>
'
+
error
.
code
);
})
};
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0300 first publish err:
'
+
JSON
.
stringify
(
err
));
});
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0300 first from own error.code ======>
'
+
error
.
code
);
});
}
if
(
want
.
action
===
'
Promise_0400
'
)
{
...
...
@@ -193,21 +194,21 @@ export default class UIExtAbility extends UIExtensionAbility {
parameters
:
{
[
wantConstant
.
Params
.
ABILITY_BACK_TO_OTHER_MISSION_STACK
]:
true
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0400 first from own data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0400 first from own data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Promise_0400 first from own data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Promise_0400 first from own data.action ======>
'
+
data
.
want
.
parameters
.
action
);
let
commonEventData
=
{
parameters
:
{
str
:
data
.
want
.
parameters
.
action
,
result
:
data
.
resultCode
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0400 first publish err:
'
+
JSON
.
stringify
(
err
));
})
}).
catch
((
error
)
=>
{
};
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>Promise_0400 first publish err:
'
+
JSON
.
stringify
(
err
));
});
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Promise_0400 first from own error.code ======>
'
+
error
.
code
);
})
})
;
}
if
(
want
.
action
===
'
Promise_0500
'
)
{
...
...
@@ -219,25 +220,25 @@ export default class UIExtAbility extends UIExtensionAbility {
parameters
:
{
[
wantConstant
.
Params
.
ABILITY_BACK_TO_OTHER_MISSION_STACK
]:
true
}
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Callback_0500 first from own data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Callback_0500 first from own data.action ======>
'
+
data
.
want
.
parameters
.
action
);
}).
catch
((
error
)
=>
{
}).
then
((
data
)
=>
{
console
.
info
(
'
=======>Callback_0500 first from own data.resultCode ======>
'
+
data
.
resultCode
);
console
.
info
(
'
=======>Callback_0500 first from own data.action ======>
'
+
data
.
want
.
parameters
.
action
);
}).
catch
((
error
)
=>
{
console
.
info
(
'
=======>Callback_0500 first from own error.code ======>
'
+
error
.
code
);
let
commonEventData
=
{
parameters
:{
num
:
error
.
code
}
let
commonEventData
=
{
parameters
:
{
num
:
error
.
code
}
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0500 first publish err:
'
+
JSON
.
stringify
(
err
));
})
})
};
commonEvent
.
publish
(
'
ACTS_CALL_EVENT
'
,
commonEventData
,
(
err
)
=>
{
console
.
debug
(
'
====>AsyncCallback_0500 first publish err:
'
+
JSON
.
stringify
(
err
));
});
});
}
}
onSessionDestroy
(
session
)
{
console
.
log
(
`onSessionDestroy`
)
console
.
log
(
'
onSessionDestroy
'
);
}
onDestroy
()
{
...
...
ability/ability_runtime/actsforresult/main/entry/src/main/ets/calledability/CalledAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -14,7 +14,7 @@
*/
import
UIAbility
from
'
@ohos.app.ability.UIAbility
'
;
import
hilog
from
'
@ohos.hilog
'
;
import
window
from
'
@ohos.window
'
;
import
type
window
from
'
@ohos.window
'
;
export
default
class
CalledAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
...
...
@@ -22,7 +22,7 @@ export default class CalledAbility extends UIAbility {
console
.
log
(
'
=====> first app CalledAbility =====>
'
);
if
(
want
.
action
==
'
AsyncCallback_0100
'
)
{
if
(
want
.
action
==
=
'
AsyncCallback_0100
'
)
{
this
.
context
.
terminateSelfWithResult
({
resultCode
:
0
,
want
:
{
...
...
@@ -32,10 +32,10 @@ export default class CalledAbility extends UIAbility {
}
},
(
err
)
=>
{
console
.
log
(
'
=====> AsyncCallback_0100 CalledAbilityCallBack terminateSelfWithResult =====>
'
+
err
.
code
);
})
})
;
}
if
(
want
.
action
==
'
Promise_0100
'
)
{
if
(
want
.
action
==
=
'
Promise_0100
'
)
{
this
.
context
.
terminateSelfWithResult
({
resultCode
:
0
,
want
:
{
...
...
@@ -45,10 +45,10 @@ export default class CalledAbility extends UIAbility {
}
},
(
err
)
=>
{
console
.
log
(
'
=====> Promise_0100 CalledAbilityCallBack terminateSelfWithResult =====>
'
+
err
.
code
);
})
})
;
}
if
(
want
.
action
==
'
AsyncCallback_0200
'
)
{
if
(
want
.
action
==
=
'
AsyncCallback_0200
'
)
{
this
.
context
.
terminateSelfWithResult
({
resultCode
:
0
,
want
:
{
...
...
@@ -58,10 +58,10 @@ export default class CalledAbility extends UIAbility {
}
},
(
err
)
=>
{
console
.
log
(
'
=====> AsyncCallback_0200 CalledAbilityCallBack terminateSelfWithResult =====>
'
+
err
.
code
);
})
})
;
}
if
(
want
.
action
==
'
Promise_0200
'
)
{
if
(
want
.
action
==
=
'
Promise_0200
'
)
{
this
.
context
.
terminateSelfWithResult
({
resultCode
:
0
,
want
:
{
...
...
@@ -71,7 +71,7 @@ export default class CalledAbility extends UIAbility {
}
},
(
err
)
=>
{
console
.
log
(
'
=====> Promise_0200 CalledAbilityCallBack terminateSelfWithResult =====>
'
+
err
.
code
);
})
})
;
}
}
...
...
ability/ability_runtime/actsforresult/main/entry/src/main/ets/entryability/EntryAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -18,72 +18,73 @@ import window from '@ohos.window';
export
default
class
EntryAbility
extends
UIAbility
{
onCreate
(
want
,
launchParam
)
{
const
TIMEOUT
=
50
;
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
Ability onCreate
'
);
globalThis
.
terminate
=
(
str
)
=>
{
setTimeout
(()
=>
{
this
.
context
.
terminateSelf
().
then
(()
=>
{
console
.
info
(
"
====>terminateSelf
"
+
JSON
.
stringify
(
str
)
+
"
end
"
);
console
.
info
(
'
====>terminateSelf
'
+
JSON
.
stringify
(
str
)
+
'
end
'
);
}).
catch
((
err
)
=>
{
console
.
info
(
"
====>terminateSelf
"
+
JSON
.
stringify
(
str
)
+
"
err:
"
+
JSON
.
stringify
(
err
));
console
.
info
(
'
====>terminateSelf
'
+
JSON
.
stringify
(
str
)
+
'
err:
'
+
JSON
.
stringify
(
err
));
});
},
50
)
},
TIMEOUT
);
};
if
(
want
.
action
==
'
AsyncCallback_0100
'
)
{
if
(
want
.
action
=
==
'
AsyncCallback_0100
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0100':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0100
"
,
action
:
'
AsyncCallback_0100
'
,
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
});
}
else
if
(
want
.
action
==
'
AsyncCallback_0300
'
)
{
}
else
if
(
want
.
action
==
=
'
AsyncCallback_0300
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0300':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0300
"
,
action
:
'
AsyncCallback_0300
'
,
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
});
}
else
if
(
want
.
action
==
'
AsyncCallback_0400
'
)
{
}
else
if
(
want
.
action
==
=
'
AsyncCallback_0400
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0400':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0400
"
,
action
:
'
AsyncCallback_0400
'
,
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
});
}
else
if
(
want
.
action
==
'
AsyncCallback_0500
'
)
{
}
else
if
(
want
.
action
==
=
'
AsyncCallback_0500
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'AsyncCallback_0500':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
AsyncCallback_0500
"
,
action
:
'
AsyncCallback_0500
'
,
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
});
}
if
(
want
.
action
==
'
Promise_0100
'
)
{
if
(
want
.
action
=
==
'
Promise_0100
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'Promise_0100':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
Promise_0100
"
,
action
:
'
Promise_0100
'
,
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
});
}
else
if
(
want
.
action
==
'
Promise_0300
'
)
{
}
else
if
(
want
.
action
==
=
'
Promise_0300
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'Promise_0300':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
Promise_0300
"
,
action
:
'
Promise_0300
'
,
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
});
}
else
if
(
want
.
action
==
'
Promise_0400
'
)
{
}
else
if
(
want
.
action
==
=
'
Promise_0400
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'Promise_0400':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
Promise_0400
"
,
action
:
'
Promise_0400
'
,
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
});
}
else
if
(
want
.
action
==
'
Promise_0500
'
)
{
}
else
if
(
want
.
action
==
=
'
Promise_0500
'
)
{
console
.
info
(
"
====>EntryAbility want.action == 'Promise_0500':
"
);
AppStorage
.
SetOrCreate
(
'
want
'
,
{
action
:
"
Promise_0500
"
,
action
:
'
Promise_0500
'
,
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
});
...
...
@@ -124,17 +125,17 @@ export default class EntryAbility extends UIAbility {
console
.
log
(
'
=======>startAbilityForResult error.code ======>
'
+
error
.
code
);
console
.
log
(
'
=======>startAbilityForResult data.resultCode ======>
'
+
data
.
resultCode
);
console
.
log
(
'
=======>startAbilityForResult data.action ======>
'
+
data
.
want
.
parameters
.
action
);
})
}
})
;
}
;
globalThis
.
startUIExtension
=
()
=>
{
this
.
context
.
startAbility
({
bundleName
:
'
com.example.mainhap
'
,
abilityName
:
'
UIExtAbility
'
,
},(
err
)
=>
{
},
(
err
)
=>
{
console
.
info
(
'
====>startAbility err:
'
+
JSON
.
stringify
(
err
));
})
}
})
;
}
;
}
onBackground
()
{
...
...
ability/ability_runtime/actsforresult/main/entry/src/main/ets/otherability/OtherAbility.ts
浏览文件 @
6bdeb4ff
...
...
@@ -16,9 +16,9 @@ import UIAbility from '@ohos.app.ability.UIAbility';
import
hilog
from
'
@ohos.hilog
'
;
import
window
from
'
@ohos.window
'
;
export
default
class
OtherAbility
extends
UIAbility
{
AsyncCallback_0300
:
number
=
0
;
asyncCallback_0300
:
number
=
0
;
onCreate
(
want
,
launchParam
)
{
console
.
log
(
'
=====> OtherAbility onCreate =====>
'
);
}
...
...
@@ -46,20 +46,20 @@ export default class OtherAbility extends UIAbility {
onForeground
()
{
console
.
log
(
'
=====> OtherAbility onForeground =====>
'
);
this
.
AsyncCallback_0300
++
;
console
.
log
(
`=====> OtherAbility AsyncCallback_0300 count:
${
this
.
AsyncCallback_0300
}
`
);
if
(
this
.
AsyncCallback_0300
===
2
)
{
this
.
context
.
terminateSelfWithResult
({
resultCode
:
0
,
want
:
{
parameters
:
{
action
:
'
ACTION
'
}
this
.
asyncCallback_0300
++
;
console
.
log
(
`=====> OtherAbility asyncCallback_0300 count:
${
this
.
asyncCallback_0300
}
`
);
if
(
this
.
asyncCallback_0300
===
2
)
{
this
.
context
.
terminateSelfWithResult
({
resultCode
:
0
,
want
:
{
parameters
:
{
action
:
'
ACTION
'
}
},
(
err
)
=>
{
console
.
log
(
'
=====> OtherAbility CalledAbilityCallBack terminateSelfWithResult =====>
'
+
err
.
code
);
})
}
}
},
(
err
)
=>
{
console
.
log
(
'
=====> OtherAbility CalledAbilityCallBack terminateSelfWithResult =====>
'
+
err
.
code
);
});
}
}
onBackground
()
{
...
...
ability/ability_runtime/actsforresult/maintest/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts
浏览文件 @
6bdeb4ff
...
...
@@ -20,44 +20,43 @@ var abilityDelegator = undefined
var
abilityDelegatorArguments
=
undefined
async
function
onAbilityCreateCallback
()
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
onAbilityCreateCallback
'
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
onAbilityCreateCallback
'
);
}
async
function
addAbilityMonitorCallback
(
err
:
any
)
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
addAbilityMonitorCallback : %{public}s
'
,
JSON
.
stringify
(
err
)
??
''
);
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
addAbilityMonitorCallback : %{public}s
'
,
JSON
.
stringify
(
err
)
??
''
);
}
export
default
class
OpenHarmonyTestRunner
implements
TestRunner
{
constructor
()
{
}
constructor
()
{
}
onPrepare
()
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
OpenHarmonyTestRunner OnPrepare
'
);
}
onPrepare
()
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
OpenHarmonyTestRunner OnPrepare
'
);
}
async
onRun
()
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
OpenHarmonyTestRunner onRun run
'
);
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
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
var
debug
=
abilityDelegatorArguments
.
parameters
[
'
-D
'
]
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
cmd : %{public}s
'
,
cmd
);
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
d
:
any
)
=>
{
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
'
);
async
onRun
()
{
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
%{public}s
'
,
'
OpenHarmonyTestRunner onRun run
'
);
abilityDelegatorArguments
=
AbilityDelegatorRegistry
.
getArguments
()
abilityDelegator
=
AbilityDelegatorRegistry
.
getAbilityDelegator
()
var
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
;
var
debug
=
abilityDelegatorArguments
.
parameters
[
'
-D
'
];
if
(
debug
==
'
true
'
)
{
cmd
+=
'
-D
'
}
hilog
.
info
(
0x0000
,
'
testTag
'
,
'
cmd : %{public}s
'
,
cmd
);
abilityDelegator
.
executeShellCommand
(
cmd
,
(
err
:
any
,
d
:
any
)
=>
{
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录