提交 15cb1c64 编写于 作者: Y yuwenze

fix uri xts

Signed-off-by: Nyuwenze <yuwenze1@huawei.com>
Change-Id: I916403a2518b87d2a5649aaa10d8e08117952a2d
上级 a71f16f6
......@@ -15,6 +15,9 @@
import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent';
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
export default class Hap2MainAbility4 extends Ability {
onCreate(want, launchParam) {
console.log('[Demo] Hap2MainAbility4 onCreate')
......@@ -75,9 +78,10 @@ export default class Hap2MainAbility4 extends Ability {
let eventName6 : string = 'Temp_UriPermissionTest_0300_Read_Successfully_';
let eventName7 : string = 'Temp_UriPermissionTest_0300_Read_Failed_';
function SubscribeCallBackContext(err, data) {
async function SubscribeCallBackContext(err, data) {
console.log(' Subscribe CallBack data:' + JSON.stringify(data));
if (data.event === eventName5) {
await sleep(1000);
globalThis.fs.open(uri, globalThis.fs.OpenMode.READ_ONLY).then((file) => {
console.info('file fd: ' + file.fd);
commonEvent.publish(eventName6, (err) => {
......
......@@ -17,6 +17,10 @@ import Ability from '@ohos.app.ability.UIAbility'
import commonEvent from '@ohos.commonEvent';
import fs from '@ohos.file.fs'
function sleep(time) {
return new Promise((resolve) => setTimeout(resolve, time))
}
export default class Hap3MainAbility1 extends Ability {
onCreate(want, launchParam) {
console.log('[Demo] Hap3MainAbility1 onCreate')
......@@ -47,9 +51,10 @@ export default class Hap3MainAbility1 extends Ability {
console.info("Hap2MainAbility1 ===UnSubscribeInfoCallback_1===")
}
function SubscribeCallBackContext(err, data) {
async function SubscribeCallBackContext(err, data) {
console.log('Hap3MainAbility1 Subscribe CallBack data:' + JSON.stringify(data));
if (data.event === eventName) {
await sleep(1000);
let uri : string = globalThis.abilityWant.uri;
if (uri == null) {
console.log('[Demo] Hap3MainAbility1 uri is invalid');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册