mirror of
https://github.com/openharmony/applications_systemui.git
synced 2026-07-20 23:45:11 -04:00
!369 system-dialog-ability visible=false
Merge pull request !369 from zhangpan/srmd4083
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -20,6 +20,6 @@ const TAG = 'Dialog-AbilityStage';
|
||||
|
||||
export default class DialogAbilityStage extends AbilityStage {
|
||||
onCreate() {
|
||||
Log.showDebug(TAG, 'onCreate')
|
||||
Log.showInfo(TAG, 'onCreate')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -19,7 +19,7 @@ import display from '@ohos.display';
|
||||
import window from '@ohos.window';
|
||||
import rpc from '@ohos.rpc';
|
||||
import Log from '../../../../../../../common/src/main/ets/default/Log';
|
||||
import Constants from '../common/Constants';
|
||||
import Constants, { ServiceStubCode } from '../common/Constants';
|
||||
import SystemDialogController from '../controller/Controller';
|
||||
import type { IDialogParameters } from '../controller/Controller';
|
||||
|
||||
@@ -34,17 +34,17 @@ const REPLY_SUCCESS_CODE = 0;
|
||||
class Stub extends rpc.RemoteObject {
|
||||
onRemoteRequest(code: number, data, reply, option) {
|
||||
const connectId = getConnectId(rpc.IPCSkeleton.getCallingPid(), rpc.IPCSkeleton.getCallingTokenId());
|
||||
Log.showDebug(TAG, `onRemoteRequest start ${connectId}`);
|
||||
Log.showInfo(TAG, `onRemoteRequest start ${connectId}`);
|
||||
|
||||
if (code === 2) {
|
||||
Log.showDebug(TAG, `onRemoteRequest code:2 start ${connectId}`);
|
||||
if (code === ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT) {
|
||||
Log.showInfo(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} start ${connectId}`);
|
||||
const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];
|
||||
const remoteObject = data.readRemoteObject();
|
||||
Log.showDebug(TAG, `onRemoteRequest code:2 ${remoteObject}`);
|
||||
Log.showDebug(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} ${remoteObject}`);
|
||||
|
||||
if (remoteObject) {
|
||||
controller.addDataByKey(connectId, { remoteObject });
|
||||
Log.showDebug(TAG, `onRemoteRequest code:2 end`);
|
||||
Log.showDebug(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_SEND_REMOTE_OBJECT} end`);
|
||||
|
||||
reply.writeInt(REPLY_SUCCESS_CODE);
|
||||
return true;
|
||||
@@ -53,17 +53,14 @@ class Stub extends rpc.RemoteObject {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (code === 1) {
|
||||
Log.showDebug(TAG, `onRemoteRequest code:1 ${connectId}`);
|
||||
if (code === ServiceStubCode.COMMAND_START_DIALOG) {
|
||||
Log.showInfo(TAG, `onRemoteRequest code:${ServiceStubCode.COMMAND_START_DIALOG} ${connectId}`);
|
||||
const size = data.readInt();
|
||||
Log.showDebug(TAG, `onRemoteRequest code:1 readInt ${size}`);
|
||||
const parameters: { [key: string]: any } = {};
|
||||
|
||||
for (let i = 0; i < size; i++) {
|
||||
const key = data.readString();
|
||||
Log.showDebug(TAG, `onRemoteRequest code:1 readString ${key}`);
|
||||
const value = data.readString();
|
||||
Log.showDebug(TAG, `onRemoteRequest code:1 readString ${value}`);
|
||||
parameters[key] = value;
|
||||
}
|
||||
|
||||
@@ -90,14 +87,14 @@ class Stub extends rpc.RemoteObject {
|
||||
|
||||
async createWindow(connectId: string, parameters: IDialogParameters) {
|
||||
const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];
|
||||
const now = controller.getData().get(connectId);
|
||||
if (now && now.windowName) {
|
||||
Log.showDebug(TAG, `createWindow <this same> connectId:${connectId}`);
|
||||
const current = controller.getData().get(connectId);
|
||||
if (current && current.windowName) {
|
||||
Log.showInfo(TAG, `createWindow <this same> connectId:${connectId}`);
|
||||
controller.destroyWindow(connectId, false);
|
||||
}
|
||||
|
||||
const windowName = `SystemDialog${++controller.count}`;
|
||||
Log.showDebug(TAG, `createWindow <start> windowName:${windowName} connectId:${connectId} parameters:${JSON.stringify(parameters)}`);
|
||||
Log.showInfo(TAG, `createWindow <start> windowName:${windowName} connectId:${connectId} parameters:${JSON.stringify(parameters)}`);
|
||||
|
||||
controller.addDataByKey(connectId, { windowName, parameters });
|
||||
|
||||
@@ -109,7 +106,7 @@ class Stub extends rpc.RemoteObject {
|
||||
height: dis.height
|
||||
};
|
||||
});
|
||||
Log.showDebug(TAG, `createWindow <getDefaultDisplay> ${JSON.stringify(navigationBarRect)}`);
|
||||
Log.showInfo(TAG, `createWindow <getDefaultDisplay> ${JSON.stringify(navigationBarRect)}`);
|
||||
const win = await window.createWindow({
|
||||
ctx: controller.getContext(),
|
||||
name: windowName,
|
||||
@@ -131,17 +128,17 @@ class Stub extends rpc.RemoteObject {
|
||||
|
||||
export default class DialogServiceExtAbility extends ServiceExtensionAbility {
|
||||
onCreate(want: Want) {
|
||||
Log.showDebug(TAG, 'onCreate');
|
||||
Log.showInfo(TAG, 'onCreate');
|
||||
globalThis[Constants.SYSTEM_DIALOG_CONTROLLER] = new SystemDialogController(this.context);
|
||||
}
|
||||
|
||||
onConnect() {
|
||||
Log.showDebug(TAG, 'onConnect');
|
||||
Log.showInfo(TAG, 'onConnect');
|
||||
return new Stub('SystemDialog');
|
||||
}
|
||||
|
||||
onDisconnect() {
|
||||
Log.showDebug(TAG, 'onDisconnect');
|
||||
Log.showInfo(TAG, 'onDisconnect');
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
@@ -149,6 +146,6 @@ export default class DialogServiceExtAbility extends ServiceExtensionAbility {
|
||||
controller.destroyAllWindow();
|
||||
globalThis[Constants.SYSTEM_DIALOG_CONTROLLER] = undefined;
|
||||
|
||||
Log.showDebug(TAG, 'onDestroy end');
|
||||
Log.showInfo(TAG, 'onDestroy end');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -18,3 +18,9 @@ const TAG = 'Dialog-constants';
|
||||
export default {
|
||||
SYSTEM_DIALOG_CONTROLLER: TAG + 'SystemDialog_Controller'
|
||||
}
|
||||
|
||||
// see ../Idl/ts/idl_system_dialog_service_stub.ts
|
||||
export class ServiceStubCode {
|
||||
static readonly COMMAND_START_DIALOG = 1;
|
||||
static readonly COMMAND_SEND_REMOTE_OBJECT = 2;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -23,7 +23,6 @@ export interface IDialogParameters {
|
||||
bundleName?: string,
|
||||
abilityName?: string,
|
||||
parameters?: { [key: string]: any },
|
||||
// type?: string
|
||||
}
|
||||
|
||||
interface ISystemDialogData {
|
||||
@@ -39,7 +38,7 @@ class SystemDialogController {
|
||||
|
||||
constructor(context) {
|
||||
this.context = context;
|
||||
Log.showDebug(TAG, `SystemDialogController constructor ${this.context}`);
|
||||
Log.showInfo(TAG, `SystemDialogController constructor ${this.context}`);
|
||||
}
|
||||
|
||||
getContext() {
|
||||
@@ -51,7 +50,7 @@ class SystemDialogController {
|
||||
}
|
||||
|
||||
getRemoteObject(key: string) {
|
||||
Log.showDebug(TAG, `getRemoteObject start ${key}`);
|
||||
Log.showInfo(TAG, `getRemoteObject start ${key}`);
|
||||
const { remoteObject } = this.data.get(key);
|
||||
|
||||
Log.showDebug(TAG, `getRemoteObject end ${remoteObject}`);
|
||||
@@ -59,18 +58,18 @@ class SystemDialogController {
|
||||
}
|
||||
|
||||
clearRemoteObject(key: string) {
|
||||
Log.showDebug(TAG, `clearRemoteObject start ${key}`);
|
||||
Log.showInfo(TAG, `clearRemoteObject start ${key}`);
|
||||
|
||||
const now = this.data.get(key);
|
||||
if (now) {
|
||||
now.remoteObject = undefined;
|
||||
const current = this.data.get(key);
|
||||
if (current) {
|
||||
current.remoteObject = undefined;
|
||||
}
|
||||
|
||||
Log.showDebug(TAG, `clearRemoteObject end ${key}`);
|
||||
}
|
||||
|
||||
addDataByKey(key: string, v: ISystemDialogData) {
|
||||
Log.showDebug(TAG, `Controller-addDataByKey start ${key} ${v}`);
|
||||
Log.showInfo(TAG, `Controller-addDataByKey start ${key} ${v}`);
|
||||
if (this.data.get(key)) {
|
||||
Object.assign(this.data.get(key), v);
|
||||
} else {
|
||||
@@ -80,15 +79,15 @@ class SystemDialogController {
|
||||
}
|
||||
|
||||
destroyWindow(key: string, needClear: boolean = true) {
|
||||
const now = this.data.get(key);
|
||||
const current = this.data.get(key);
|
||||
|
||||
if (!now) {
|
||||
Log.showDebug(TAG, `destroyWindow fail. key:${key} not exist`);
|
||||
if (!current) {
|
||||
Log.showInfo(TAG, `destroyWindow fail. key:${key} not exist`);
|
||||
return;
|
||||
}
|
||||
|
||||
const { windowName } = now;
|
||||
Log.showDebug(TAG, `destroyWindow start ${key} ${windowName}`);
|
||||
const { windowName } = current;
|
||||
Log.showInfo(TAG, `destroyWindow start ${key} ${windowName}`);
|
||||
|
||||
if (windowName) {
|
||||
const win = window.findWindow(windowName);
|
||||
@@ -112,7 +111,7 @@ class SystemDialogController {
|
||||
}
|
||||
|
||||
destroyAllWindow() {
|
||||
Log.showDebug(TAG, `destroyAllWindow start`);
|
||||
Log.showInfo(TAG, `destroyAllWindow start`);
|
||||
this.data.forEach((v, key) => {
|
||||
this.destroyWindow(key);
|
||||
})
|
||||
@@ -120,7 +119,7 @@ class SystemDialogController {
|
||||
}
|
||||
|
||||
clear() {
|
||||
Log.showDebug(TAG, `clear start`);
|
||||
Log.showInfo(TAG, `clear start`);
|
||||
this.data.clear();
|
||||
this.context.terminateSelf();
|
||||
this.context = null;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -30,11 +30,11 @@ struct Index {
|
||||
@LocalStorageProp('parameters') parameters: IDialogParameters = undefined;
|
||||
|
||||
aboutToAppear() {
|
||||
Log.showDebug(TAG, `aboutToAppear r ${this.connectId} ${this.windowName} ${JSON.stringify(this.parameters)}`)
|
||||
Log.showInfo(TAG, `aboutToAppear r ${this.connectId} ${this.windowName} ${JSON.stringify(this.parameters)}`)
|
||||
}
|
||||
|
||||
aboutToDisappear() {
|
||||
Log.showDebug(TAG, `aboutToDisappear ${this.connectId} ${this.windowName} ${JSON.stringify(this.parameters)}`)
|
||||
Log.showInfo(TAG, `aboutToDisappear ${this.connectId} ${this.windowName} ${JSON.stringify(this.parameters)}`)
|
||||
}
|
||||
|
||||
onOk() {
|
||||
@@ -61,14 +61,14 @@ struct Index {
|
||||
});
|
||||
}
|
||||
|
||||
Log.showDebug(TAG, 'onOk end');
|
||||
Log.showInfo(TAG, 'onOk end');
|
||||
}
|
||||
|
||||
onClose() {
|
||||
Log.showDebug(TAG, `onClose start`);
|
||||
const controller = globalThis[Constants.SYSTEM_DIALOG_CONTROLLER];
|
||||
controller.destroyWindow(this.connectId);
|
||||
Log.showDebug(TAG, `onClose end`);
|
||||
Log.showInfo(TAG, `onClose end`);
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"pages": "$profile:main_pages",
|
||||
"extensionAbilities": [
|
||||
{
|
||||
"visible": true,
|
||||
"visible": false,
|
||||
"srcEntrance": "./ets/ServiceExtAbility/ExtAbility.ts",
|
||||
"name": "com.ohos.systemui.dialog",
|
||||
"description": "$string:mainability_description",
|
||||
|
||||
Reference in New Issue
Block a user