From c03415c9982945327395330191fc93914848d933 Mon Sep 17 00:00:00 2001 From: caochunlei Date: Tue, 12 Jul 2022 19:09:40 +0800 Subject: [PATCH 1/2] caochunlei1@huawei.com Signed-off-by: caochunlei --- api/@ohos.application.Ability.d.ts | 12 ++ api/@ohos.application.Extension.d.ts | 109 ++++++++++++ api/@ohos.application.appManager.d.ts | 27 +++ api/application/ConnectStateData.d.ts | 97 +++++++++++ api/application/ConnectionStateObserver.d.ts | 71 ++++++++ api/application/DlpStateData.d.ts | 78 +++++++++ api/application/MissionListener.d.ts | 164 ++++++++++--------- api/application/ServiceExtensionContext.d.ts | 14 +- 8 files changed, 494 insertions(+), 78 deletions(-) create mode 100644 api/@ohos.application.Extension.d.ts create mode 100644 api/application/ConnectStateData.d.ts create mode 100644 api/application/ConnectionStateObserver.d.ts create mode 100644 api/application/DlpStateData.d.ts diff --git a/api/@ohos.application.Ability.d.ts b/api/@ohos.application.Ability.d.ts index 8a89bbc773..91f91459d5 100755 --- a/api/@ohos.application.Ability.d.ts +++ b/api/@ohos.application.Ability.d.ts @@ -302,4 +302,16 @@ export default class Ability { * @StageModelOnly */ dump(params: Array): Array; + + /** + * Called when the system has determined to trim the memory, for example, when the ability is running in the + * background and there is no enough memory for running as many background processes as possible. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param level Indicates the memory trim level, which shows the current memory usage status. + * @return - + * @StageModelOnly + */ + onMemoryLevel(level: number): void; } diff --git a/api/@ohos.application.Extension.d.ts b/api/@ohos.application.Extension.d.ts new file mode 100644 index 0000000000..83f31ad2b9 --- /dev/null +++ b/api/@ohos.application.Extension.d.ts @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import rpc from "./@ohos.rpc"; +import Want from './@ohos.application.Want'; +import { Configuration } from './@ohos.application.Configuration'; + +/** + * class of extension. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @StageModelOnly + */ +export default class Extension { + /** + * Called back when an extension is started for initialization. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates the want of created extension. + * @return - + * @StageModelOnly + */ + onCreate(want: Want): void; + + /** + * Called back before an extension is destroyed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + * @return - + * @StageModelOnly + */ + onDestroy(): void; + + /** + * Called back when an extension is started. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates the want of extension to start. + * @param startId Indicates the number of times the extension has been started. The {@code startId} is + * incremented by 1 every time the extension is started. For example, if the extension + * has been started for six times. + * @return - + * @StageModelOnly + */ + onRequest(want: Want, startId: number): void; + + /** + * Called back when an extension is first connected to an ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates connection information about the Extension. + * @systemapi hide for inner use. + * @return Returns the proxy of the extension. + * @StageModelOnly + */ + onConnect(want: Want): rpc.RemoteObject; + + /** + * Called back when all abilities connected to an extension are disconnected. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates disconnection information about the extension. + * @return - + * @StageModelOnly + */ + onDisconnect(want: Want): void; + + /** + * Called when the system configuration is updated. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param config Indicates the updated configuration. + * @return - + * @StageModelOnly + */ + onConfigurationUpdated(config: Configuration): void; + + /** + * Called when the system has determined to trim the memory, for example, when the ability is running in the + * background and there is no enough memory for running as many background processes as possible. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore + * @param level Indicates the memory trim level, which shows the current memory usage status. + * @return - + * @StageModelOnly + */ + onMemoryLevel(level: number): void; +} diff --git a/api/@ohos.application.appManager.d.ts b/api/@ohos.application.appManager.d.ts index a116e01990..2cfcc660c3 100644 --- a/api/@ohos.application.appManager.d.ts +++ b/api/@ohos.application.appManager.d.ts @@ -17,6 +17,7 @@ import { AsyncCallback } from './basic'; import ApplicationStateObserver from './application/ApplicationStateObserver'; import AppStateData from './application/AppStateData'; import { ProcessRunningInfo } from './application/ProcessRunningInfo'; +import ConnectionStateObserver from './application/ConnectionStateObserver'; /** * This module provides the function of app manager service. @@ -139,6 +140,32 @@ declare namespace appManager { */ function getAppMemorySize(): Promise; function getAppMemorySize(callback: AsyncCallback): void; + + /** + * Register application state observer. + * + * @default - + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param observer The connection state observer. + * @systemapi hide this for inner system use + * @return Returns the number code of the observer. + * @permission ohos.permission.RUNNING_STATE_OBSERVER + */ + function registerConnectionStateObserver(observer: ConnectionStateObserver): number; + + /** + * Unregister connection state observer. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param observerId Indicates the number code of the observer. + * @systemapi hide this for inner system use + * @return - + * @permission ohos.permission.RUNNING_STATE_OBSERVER + */ + function unregisterConnectionStateObserver(observerId: number, callback: AsyncCallback): void; + function unregisterConnectionStateObserver(observerId: number): Promise; } export default appManager; diff --git a/api/application/ConnectStateData.d.ts b/api/application/ConnectStateData.d.ts new file mode 100644 index 0000000000..2a7df24ad4 --- /dev/null +++ b/api/application/ConnectStateData.d.ts @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2021 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ElementName } from '../bundle/elementName'; +import bundle from '../@ohos.bundle'; + +/** + * The extension connection state data. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + * @permission N/A + */ +export default class ConnectStateData { + /** + * @default Indicates the callee extension. + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide this for inner system use + */ + extension: ElementName; + + /** + * The extension pid. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + extensionPid: number; + + /** + * The extension uid. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + extensionUid: number; + + /** + * @default Enumerates types of the extension. + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide this for inner system use + */ + extensionType: bundle.ExtensionAbilityType; + + /** + * The extension state. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + extensionState: number; + + /** + * The caller pid. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + callerPid: number; + + /** + * The caller uid. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + callerUid: number; + + /** + * The caller bundleName. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + callerBundleName: string; +} \ No newline at end of file diff --git a/api/application/ConnectionStateObserver.d.ts b/api/application/ConnectionStateObserver.d.ts new file mode 100644 index 0000000000..1b887bc3b2 --- /dev/null +++ b/api/application/ConnectionStateObserver.d.ts @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2021 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ConnectStateData from "./ConnectStateData"; +import DlpStateData from "./DlpStateData"; + +/** + * The application state observer. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + * @permission N/A + */ +export default class ConnectionStateObserver { + /** + * Will be called when extension is connected. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param connectData State changed connection info. + * @systemapi hide for inner use. + * @return - + */ + onExtensionConnected(connectData: ConnectStateData): void; + + /** + * Will be called when extension is disconnected. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param connectData State changed connection info. + * @systemapi hide for inner use. + * @return - + */ + onExtensionDisConnected(connectData: ConnectStateData): void; + + /** + * Will be called when dlp open an ability. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param dlpStateData State changed dlp state info. + * @systemapi hide for inner use. + * @return - + */ + onDlpAbilityOpened(dlpStateData: DlpStateData): void; + + /** + * Will be called when ability that opened by dlp is closed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param dlpStateData State changed dlp state info. + * @systemapi hide for inner use. + * @return - + */ + onDlpAbilityClosed(abilityStateData: DlpStateData): void; +} \ No newline at end of file diff --git a/api/application/DlpStateData.d.ts b/api/application/DlpStateData.d.ts new file mode 100644 index 0000000000..0a27e6cd68 --- /dev/null +++ b/api/application/DlpStateData.d.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2021 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ElementName } from '../bundle/elementName'; + +/** + * The extension connection state data. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + * @permission N/A + */ +export default class DlpStateData { + /** + * @default Indicates the target ability started by dlp. + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide this for inner system use + */ + targetAbility: ElementName; + + /** + * The target pid started by dlp. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + targetPid: number; + + /** + * The target uid started by dlp. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + targetUid: number; + + /** + * The dlp pid. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + dlpPid: number; + + /** + * The dlp uid. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide for inner use. + */ + dlpUid: number; + + /** + * @default dlp application bundle name. + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @systemapi hide this for inner system use + */ + dlpBundleName: string; +} \ No newline at end of file diff --git a/api/application/MissionListener.d.ts b/api/application/MissionListener.d.ts index 07c409538a..56064834a9 100644 --- a/api/application/MissionListener.d.ts +++ b/api/application/MissionListener.d.ts @@ -1,78 +1,88 @@ -/* - * Copyright (c) 2021-2022 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 - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import image from "../@ohos.multimedia.image"; - -/** - * MissionListener registered by app. - * - * @name MissionListener - * @since 8 - * @syscap SystemCapability.Ability.AbilityRuntime.Mission - * @permission N/A - * @systemapi hide for inner use. - */ - export interface MissionListener { - /** - * Called by system when mission created. - * - * @since 8 - * @syscap SystemCapability.Ability.AbilityRuntime.Mission - * @param mission Indicates the id of created mission. - * @return - - */ - onMissionCreated(mission: number): void; - - /** - * Called by system when mission destroyed. - * - * @since 8 - * @syscap SystemCapability.Ability.AbilityRuntime.Mission - * @param mission Indicates the id of destroyed mission. - * @return - - */ - onMissionDestroyed(mission: number): void; - - /** - * Called by system when mission shapshot changed. - * - * @since 8 - * @syscap SystemCapability.Ability.AbilityRuntime.Mission - * @param mission Indicates the id of the mission which the snapshot changes - * @return - - */ - onMissionSnapshotChanged(mission: number): void; - - /** - * Called by system when mission moved to fornt. - * - * @since 8 - * @syscap SystemCapability.Ability.AbilityRuntime.Mission - * @param mission Indicates the id of the mission being moved to the foreground. - * @return - - */ - onMissionMovedToFront(mission: number): void; - - /** - * Called by system when mission icon has changed. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Mission - * @param mission Indicates the id of the mission whose icon has changed. - * @param icon Indicates the icon of the mission whose icon has changed. - * @return - - */ - onMissionIconUpdated(mission: number, icon: image.PixelMap): void; +/* + * Copyright (c) 2021-2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import image from "../@ohos.multimedia.image"; + +/** + * MissionListener registered by app. + * + * @name MissionListener + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @permission N/A + * @systemapi hide for inner use. + */ + export interface MissionListener { + /** + * Called by system when mission created. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @param mission Indicates the id of created mission. + * @return - + */ + onMissionCreated(mission: number): void; + + /** + * Called by system when mission destroyed. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @param mission Indicates the id of destroyed mission. + * @return - + */ + onMissionDestroyed(mission: number): void; + + /** + * Called by system when mission shapshot changed. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @param mission Indicates the id of the mission which the snapshot changes + * @return - + */ + onMissionSnapshotChanged(mission: number): void; + + /** + * Called by system when mission moved to fornt. + * + * @since 8 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @param mission Indicates the id of the mission being moved to the foreground. + * @return - + */ + onMissionMovedToFront(mission: number): void; + + /** + * Called by system when mission icon has changed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @param mission Indicates the id of the mission whose icon has changed. + * @param icon Indicates the icon of the mission whose icon has changed. + * @return - + */ + onMissionIconUpdated(mission: number, icon: image.PixelMap): void; + + /** + * Called by system when target mission is closed. + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Mission + * @param mission Indicates the id of the mission whose icon has changed. + * @return - + */ + onMissionClosed(mission: number): void; } \ No newline at end of file diff --git a/api/application/ServiceExtensionContext.d.ts b/api/application/ServiceExtensionContext.d.ts index ee956cba6d..7e1c8f983a 100644 --- a/api/application/ServiceExtensionContext.d.ts +++ b/api/application/ServiceExtensionContext.d.ts @@ -19,6 +19,7 @@ import ExtensionContext from "./ExtensionContext"; import Want from "../@ohos.application.Want"; import StartOptions from "../@ohos.application.StartOptions"; import { ExtensionAbilityInfo } from "../bundle/extensionAbilityInfo"; +import Caller from '../@ohos.application.Ability'; /** * The context of service extension. It allows access to @@ -89,7 +90,7 @@ export default class ServiceExtensionContext extends ExtensionContext { */ startServiceExtensionAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback): void; startServiceExtensionAbilityWithAccount(want: Want, accountId: number): Promise; - + /** * Stops a service within the same application. * @@ -178,4 +179,15 @@ export default class ServiceExtensionContext extends ExtensionContext { */ disconnectAbility(connection: number, callback:AsyncCallback): void; disconnectAbility(connection: number): Promise; + + /** + * Get the caller object of the startup capability + * + * @since 9 + * @syscap SystemCapability.Ability.AbilityRuntime.Core + * @param want Indicates the ability to start. + * @return Returns to the Caller interface on success Returns empty or undefined on failure + * @StageModelOnly + */ + startAbilityByCall(want: Want): Promise; } \ No newline at end of file -- Gitee From 082428f3b8d66993930b30b84d0a4d3f1dd00631 Mon Sep 17 00:00:00 2001 From: caochunlei Date: Wed, 13 Jul 2022 14:44:48 +0800 Subject: [PATCH 2/2] caochunlei1@huawei.com Signed-off-by: caochunlei --- api/@ohos.application.Extension.d.ts | 61 --------------------------- api/application/ConnectStateData.d.ts | 9 ---- 2 files changed, 70 deletions(-) diff --git a/api/@ohos.application.Extension.d.ts b/api/@ohos.application.Extension.d.ts index 83f31ad2b9..37ff6fb7b7 100644 --- a/api/@ohos.application.Extension.d.ts +++ b/api/@ohos.application.Extension.d.ts @@ -13,8 +13,6 @@ * limitations under the License. */ -import rpc from "./@ohos.rpc"; -import Want from './@ohos.application.Want'; import { Configuration } from './@ohos.application.Configuration'; /** @@ -25,65 +23,6 @@ import { Configuration } from './@ohos.application.Configuration'; * @StageModelOnly */ export default class Extension { - /** - * Called back when an extension is started for initialization. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want of created extension. - * @return - - * @StageModelOnly - */ - onCreate(want: Want): void; - - /** - * Called back before an extension is destroyed. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @systemapi hide for inner use. - * @return - - * @StageModelOnly - */ - onDestroy(): void; - - /** - * Called back when an extension is started. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates the want of extension to start. - * @param startId Indicates the number of times the extension has been started. The {@code startId} is - * incremented by 1 every time the extension is started. For example, if the extension - * has been started for six times. - * @return - - * @StageModelOnly - */ - onRequest(want: Want, startId: number): void; - - /** - * Called back when an extension is first connected to an ability. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates connection information about the Extension. - * @systemapi hide for inner use. - * @return Returns the proxy of the extension. - * @StageModelOnly - */ - onConnect(want: Want): rpc.RemoteObject; - - /** - * Called back when all abilities connected to an extension are disconnected. - * - * @since 9 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @param want Indicates disconnection information about the extension. - * @return - - * @StageModelOnly - */ - onDisconnect(want: Want): void; - /** * Called when the system configuration is updated. * diff --git a/api/application/ConnectStateData.d.ts b/api/application/ConnectStateData.d.ts index 2a7df24ad4..1a63bd67c7 100644 --- a/api/application/ConnectStateData.d.ts +++ b/api/application/ConnectStateData.d.ts @@ -59,15 +59,6 @@ export default class ConnectStateData { */ extensionType: bundle.ExtensionAbilityType; - /** - * The extension state. - * - * @since 8 - * @syscap SystemCapability.Ability.AbilityRuntime.Core - * @systemapi hide for inner use. - */ - extensionState: number; - /** * The caller pid. * -- Gitee