add query index interface

Signed-off-by: yuwenze <yuwenze1@huawei.com>
Change-Id: I15bd2794cd69263e9ff4f898a948ac3cc679c66a
This commit is contained in:
yuwenze 2024-05-20 11:15:16 +08:00
parent 26fcf2c773
commit dbcbcb2994
5 changed files with 221 additions and 0 deletions

View File

@ -28,6 +28,7 @@ import { ProcessInformation as _ProcessInformation } from './application/Process
import * as _AbilityFirstFrameStateObserver from './application/AbilityFirstFrameStateObserver';
import * as _AbilityFirstFrameStateData from './application/AbilityFirstFrameStateData';
import bundleManager from './@ohos.bundle.bundleManager';
import { RunningMultiAppInfo as _RunningMultiAppInfo } from './application/RunningMultiAppInfo';
/**
* This module provides the function of app manager service.
@ -865,9 +866,28 @@ declare namespace appManager {
*/
function preloadApplication(bundleName: string, userId: number, mode: PreloadMode, appIndex?: number): Promise<void>;
/**
* Get all running multi app info by bundleName
*
* @permission ohos.permission.GET_RUNNING_INFO
* @param { string } bundleName - The bundle name of the application to query.
* @returns { Promise<RunningMultiAppInfo> } Returns the {@link RunningMultiAppInfo} for given bundle.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Not system application.
* @throws { BusinessError } 401 - Parameter error. Possible causes: 1. Mandatory parameters are left unspecified;
* 2. Incorrect parameter types; 3. Parameter verification failed.
* @throws { BusinessError } 16000072 - App clone or multi-instance is not supported.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @stagemodelonly
* @since 12
*/
function getRunningMultiAppInfo(bundleName: string): Promise<RunningMultiAppInfo>;
/**
* The ability or extension state data.
*
* @typedef { _AbilityStateData.default }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 9
@ -877,6 +897,7 @@ declare namespace appManager {
/**
* The application state data.
*
* @typedef { _AppStateData.default }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 9
@ -886,6 +907,7 @@ declare namespace appManager {
/**
* The application state observer.
*
* @typedef { _ApplicationStateObserver.default }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 9
@ -895,6 +917,7 @@ declare namespace appManager {
/**
* The application foreground state observer.
*
* @typedef { _AppForegroundStateObserver.default }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 11
@ -910,6 +933,7 @@ declare namespace appManager {
/**
* The class of a process information.
*
* @typedef { _ProcessInformation }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @atomicservice
* @since 11
@ -919,6 +943,7 @@ declare namespace appManager {
/**
* The class of a process information.
*
* @typedef { _ProcessData.default }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 10
@ -928,6 +953,7 @@ declare namespace appManager {
/**
* The ability first frame state observer.
*
* @typedef { _AbilityFirstFrameStateObserver.default }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
@ -943,6 +969,17 @@ declare namespace appManager {
* @since 12
*/
export type AbilityFirstFrameStateData = _AbilityFirstFrameStateData.default;
/**
* The class of running multi app information.
*
* @typedef { _RunningMultiAppInfo }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @atomicservice
* @since 12
*/
export type RunningMultiAppInfo = _RunningMultiAppInfo;
}
export default appManager;

View File

@ -503,4 +503,17 @@ export default class ApplicationContext extends Context {
* @since 12
*/
setSupportedProcessCache(isSupported : boolean): void;
/**
* Get current app clone index.
*
* @returns { number } Returns the app clone index for current app.
* @throws { BusinessError } 16000011 - The context does not exist.
* @throws { BusinessError } 16000071 - The MultiAppMode is not {@link APP_CLONE}.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @stagemodelonly
* @atomicservice
* @since 12
*/
getCurrentAppCloneIndex(): number;
}

49
api/application/MultiAppMode.d.ts vendored Normal file
View File

@ -0,0 +1,49 @@
/*
* Copyright (c) 2024 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.
*/
/**
* @file
* @kit AbilityKit
*/
/**
* Type of app multi app mode.
* @enum { number }
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @systemapi
* @StageModelOnly
* @since 12
*/
export enum MultiAppMode {
/**
* Indicates the type of not support app multi instance.
*
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @systemapi
* @StageModelOnly
* @since 12
*/
NOT_SUPPORTED = 0,
/**
* Indicates the type of app clone.
*
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @systemapi
* @StageModelOnly
* @since 12
*/
APP_CLONE = 2
}

59
api/application/RunningAppClone.d.ts vendored Normal file
View File

@ -0,0 +1,59 @@
/*
* Copyright (c) 2024 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.
*/
/**
* @file
* @kit AbilityKit
*/
/**
* The class of single running app information.
*
* @typedef RunningAppClone
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
*/
export interface RunningAppClone {
/**
* The app clone index of current single app.
*
* @type { number }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
*/
appCloneIndex: number;
/**
* The uid of current single app.
*
* @type { number }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
*/
uid: number;
/**
* All pids of current single app.
*
* @type { Array<number> }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
*/
pids: Array<number>;
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (c) 2024 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.
*/
/**
* @file
* @kit AbilityKit
*/
import { MultiAppMode } from './MultiAppMode';
import { RunningAppClone } from './RunningAppClone';
/**
* The class of running multi app information.
*
* @typedef RunningMultiAppInfo
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
*/
export interface RunningMultiAppInfo {
/**
* @type { string }
* @default the name of the bundle
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
*/
bundleName: string;
/**
* The app multi mode.
*
* @type { MultiAppMode }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
*/
mode: MultiAppMode;
/**
* All running app info for bundle if mode is {@link APP_CLONE}.
*
* @type { ?Array<RunningAppClone> }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @systemapi
* @since 12
*/
runningAppClones?: Array<RunningAppClone>;
}