!235 告警修改

Merge pull request !235 from yu/warnfix0412-2
This commit is contained in:
openharmony_ci 2024-04-14 04:54:30 +00:00 committed by Gitee
commit e785f5dd32
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 24 additions and 21 deletions

View File

@ -65,10 +65,6 @@ export default class ServiceExtensionAbility extends extension {
}
private async createWindow(name: string, windowType, rect, want): Promise<void> {
let proxy = want.parameters['ohos.ability.params.callback'].value;
let option = new rpc.MessageOption();
let data = new rpc.MessageSequence();
let reply = new rpc.MessageSequence();
let requestInfo: dialogRequest.RequestInfo;
try {
requestInfo = dialogRequest.getRequestInfo(want);
@ -83,22 +79,7 @@ export default class ServiceExtensionAbility extends extension {
const win = await window.createWindow({ ctx: this.context, name, windowType });
console.info(TAG + 'createWindow end.');
let storage: LocalStorage = new LocalStorage({ 'want': want, 'win': win });
await win.bindDialogTarget(want.parameters['ohos.ability.params.token'].value, () => {
Promise.all([
data.writeInterfaceToken(ACCESS_TOKEN),
]).then(() => {
proxy.sendMessageRequest(RESULT_CODE_1, data, reply, option);
}).catch(() => {
console.error('write result failed!');
})
let windowNum = GlobalContext.load('windowNum');
windowNum --;
GlobalContext.store('windowNum', windowNum);
win.destroyWindow();
if (windowNum === 0) {
this.context.terminateSelf();
}
});
await this.BindDialogTarget(win, want);
console.info(TAG + 'bindDialogTarget end.');
await win.moveWindowTo(rectInfo.left, rectInfo.top);
console.info(TAG + 'moveWindowTo end.');
@ -119,4 +100,26 @@ export default class ServiceExtensionAbility extends extension {
console.info(TAG + 'window create failed!');
}
}
private async BindDialogTarget(win, want): Promise<void> {
let proxy = want.parameters['ohos.ability.params.callback'].value;
let option = new rpc.MessageOption();
let data = new rpc.MessageSequence();
let reply = new rpc.MessageSequence();
win.bindDialogTarget(want.parameters['ohos.ability.params.token'].value, () => {
Promise.all([
data.writeInterfaceToken(ACCESS_TOKEN),
]).then(() => {
proxy.sendMessageRequest(RESULT_CODE_1, data, reply, option);
}).catch(() => {
console.error('write result failed!');
});
let windowNum = GlobalContext.load('windowNum');
windowNum --;
GlobalContext.store('windowNum', windowNum);
win.destroyWindow();
if (windowNum === 0) {
this.context.terminateSelf();
}
});
}
};

View File

@ -319,7 +319,7 @@ export default class Constants {
public static RESULT_SUCCESS = 1
public static RESULT_FAILURE = 0
public static RESULT_CODE = 0
static RESULT_CODE_1 = 1
public static RESULT_CODE_1 = 1
//location status
public static LOCATION_NONE = 0