Merge branch 'master' of gitee.com:openharmony/interface_sdk-js into master

Signed-off-by: xinking129 <xinxin13@huawei.com>
This commit is contained in:
xinking129 2023-05-23 02:09:06 +00:00 committed by Gitee
commit 96cb7279ab
50 changed files with 12567 additions and 2801 deletions

View File

@ -193,6 +193,56 @@ declare const Styles: MethodDecorator;
*/
declare const Extend: MethodDecorator & ((value: any) => MethodDecorator);
/**
* Define AnimatableExtend MethodDecorator
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
declare const AnimatableExtend: MethodDecorator & ((value: Object) => MethodDecorator);
/**
* Define AnimatableArithmetic interface
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
declare interface AnimatableArithmetic<T> {
/**
* Define plus method
* @param rhs { AnimatableArithmetic<T> } another value
* @returns { AnimatableArithmetic<T> } new value which implements AnimatableArithmetic<T> interface
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
plus(rhs: AnimatableArithmetic<T>): AnimatableArithmetic<T>;
/**
* Define subtract method
* @param rhs { AnimatableArithmetic<T> } another value
* @returns { AnimatableArithmetic<T> } new value which implements AnimatableArithmetic<T> interface
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
subtract(rhs: AnimatableArithmetic<T>): AnimatableArithmetic<T>;
/**
* Define multiply method
* @param scale { number } scale value
* @returns { AnimatableArithmetic<T> } new value which implements AnimatableArithmetic<T> interface
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
multiply(scale: number): AnimatableArithmetic<T>;
/**
* Define equals method
* @param rhs { AnimatableArithmetic<T> } another value
* @returns { boolean } is equals
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
equals(rhs: AnimatableArithmetic<T>): boolean;
}
/**
* Defining Concurrent MethodDecorator
* @since 9
@ -2919,14 +2969,14 @@ declare class CommonMethod<T> {
* @form
* @since 9
*/
borderStyle(value: BorderStyle): T;
/**
* Border style
* @param { BorderStyle | EdgeStyles } value
* @form
* @since 9
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
borderStyle(value: EdgeStyles): T;
borderStyle(value: BorderStyle | EdgeStyles): T;
/**
* Border width
@ -2937,18 +2987,14 @@ declare class CommonMethod<T> {
* @form
* @since 9
*/
borderWidth(value: Length): T;
/**
* Border width
* @since 9
*/
/**
* Border width
* @param { Length | EdgeWidths } value
* @form
* @since 9
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
borderWidth(value: EdgeWidths): T;
borderWidth(value: Length | EdgeWidths): T;
/**
* Border color
@ -2959,14 +3005,14 @@ declare class CommonMethod<T> {
* @form
* @since 9
*/
borderColor(value: ResourceColor): T;
/**
* Border color
* @param { ResourceColor | EdgeColors } value
* @form
* @since 9
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
borderColor(value: EdgeColors): T;
borderColor(value: ResourceColor | EdgeColors): T;
/**
* Border radius
@ -2977,14 +3023,14 @@ declare class CommonMethod<T> {
* @form
* @since 9
*/
borderRadius(value: Length): T;
/**
* Border radius
* @param { Length | BorderRadiuses } value
* @form
* @since 9
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
borderRadius(value: BorderRadiuses): T;
borderRadius(value: Length | BorderRadiuses): T;
/**
* Border image

View File

@ -283,6 +283,17 @@ declare class SearchAttribute extends CommonMethod<SearchAttribute> {
* @since 9
*/
textAlign(value: TextAlign): SearchAttribute;
/**
* Sets whether request keyboard or not when on focus.
* @param { boolean }
* @default true
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @returns { SearchAttribute } Returns the instance of the SearchAttribute.
* @crossplatform
* @since 10
*/
enableKeyboardOnFocus(value: boolean): SearchAttribute;
}
/**

View File

@ -177,6 +177,17 @@ declare class TextAreaAttribute extends CommonMethod<TextAreaAttribute> {
* @since 9
*/
copyOption(value: CopyOptions): TextAreaAttribute;
/**
* Sets whether request keyboard or not when on focus.
* @param { boolean }
* @default true
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @returns { TextAreaInterface } Returns the instance of the TextAreaInterface.
* @crossplatform
* @since 10
*/
enableKeyboardOnFocus(value: boolean): TextAreaInterface;
}
/**

View File

@ -348,6 +348,17 @@ declare class TextInputAttribute extends CommonMethod<TextInputAttribute> {
* @since 10
*/
caretPosition(value: number): TextInputAttribute;
/**
* Sets whether request keyboard or not when on focus.
* @param { boolean }
* @default true
* @returns { TextInputAttribute } Returns the instance of the TextInputAttribute.
* @crossplatform
* @syscap SystemCapability.ArkUI.ArkUI.Full
* @since 10
*/
enableKeyboardOnFocus(value: boolean): TextInputAttribute;
}
/**

View File

@ -19,9 +19,16 @@
* @namespace AbilityConstant
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* The definition of AbilityConstant.
* @namespace AbilityConstant
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
declare namespace AbilityConstant {
/**
* Interface of launch param.
@ -29,18 +36,31 @@ declare namespace AbilityConstant {
* @typedef LaunchParam
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Interface of launch param.
* @typedef LaunchParam
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export interface LaunchParam {
/**
* Indicates launch reason.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates launch reason.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
launchReason: LaunchReason;
/**
@ -48,9 +68,15 @@ declare namespace AbilityConstant {
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates last exit reason.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
lastExitReason: LastExitReason;
}
@ -60,18 +86,30 @@ declare namespace AbilityConstant {
* @enum { number }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Type of launch reason.
* @enum { number }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export enum LaunchReason {
/**
* Unknown reason.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
UNKNOWN = 0,
/**
@ -125,18 +163,30 @@ declare namespace AbilityConstant {
* @enum { number }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Type of last exit reason.
* @enum { number }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export enum LastExitReason {
/**
* Unknown reason.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
UNKNOWN = 0,
/**

View File

@ -22,9 +22,15 @@ import window from './@ohos.window';
*
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* The ability lifecycle callback.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
export default class AbilityLifecycleCallback {
/**
* Called back when an ability is started for initialization.
@ -32,9 +38,16 @@ export default class AbilityLifecycleCallback {
* @param { UIAbility } ability - Indicates the ability to register for listening.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when an ability is started for initialization.
* @param { Ability } ability - Indicates the ability to register for listening.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onAbilityCreate(ability: UIAbility): void;
/**
@ -44,9 +57,17 @@ export default class AbilityLifecycleCallback {
* @param { window.WindowStage } windowStage - window stage to create
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when a window stage is created.
* @param { Ability } ability - Indicates the ability to register for listening.
* @param { window.WindowStage } windowStage - window stage to create
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onWindowStageCreate(ability: UIAbility, windowStage: window.WindowStage): void;
/**
@ -78,9 +99,17 @@ export default class AbilityLifecycleCallback {
* @param { window.WindowStage } windowStage - window stage to destroy
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when a window stage is destroyed.
* @param { Ability } ability - Indicates the ability to register for listening.
* @param { window.WindowStage } windowStage - window stage to destroy
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onWindowStageDestroy(ability: UIAbility, windowStage: window.WindowStage): void;
/**
@ -89,9 +118,16 @@ export default class AbilityLifecycleCallback {
* @param { UIAbility } ability - Indicates the ability to register for listening.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when an ability is destroyed.
* @param { Ability } ability - Indicates the ability to register for listening.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onAbilityDestroy(ability: UIAbility): void;
/**
@ -100,9 +136,16 @@ export default class AbilityLifecycleCallback {
* @param { UIAbility } ability - Indicates the ability to register for listening.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when the state of an ability changes to foreground.
* @param { Ability } ability - Indicates the ability to register for listening.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onAbilityForeground(ability: UIAbility): void;
/**
@ -111,9 +154,16 @@ export default class AbilityLifecycleCallback {
* @param { UIAbility } ability - Indicates the ability to register for listening.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when the state of an ability changes to background.
* @param { Ability } ability - Indicates the ability to register for listening.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onAbilityBackground(ability: UIAbility): void;
/**

View File

@ -23,9 +23,15 @@ import { Configuration } from './@ohos.app.ability.Configuration';
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* The class of an ability stage.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export default class AbilityStage {
/**
* Indicates configuration information about context.
@ -33,9 +39,16 @@ export default class AbilityStage {
* @type { AbilityStageContext }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates configuration information about context.
* @type { AbilityStageContext }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
context: AbilityStageContext;
/**
@ -43,9 +56,15 @@ export default class AbilityStage {
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when an ability stage is started for initialization.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
onCreate(): void;
/**
@ -67,9 +86,16 @@ export default class AbilityStage {
* @param { Configuration } newConfig - Indicates the updated configuration.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called when the system configuration is updated.
* @param { Configuration } newConfig - Indicates the updated configuration.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
onConfigurationUpdate(newConfig: Configuration): void;
/**

View File

@ -20,9 +20,15 @@ import ConfigurationConstant from './@ohos.app.ability.ConfigurationConstant';
*
* @typedef Configuration
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* configuration item.
* @typedef Configuration
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
export interface Configuration {
/**
* Indicates the current language of the application.
@ -38,9 +44,15 @@ export interface Configuration {
*
* @type { ?ConfigurationConstant.ColorMode }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* Indicates the current colorMode of the application.
* @type { ConfigurationConstant.ColorMode }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
colorMode?: ConfigurationConstant.ColorMode;
/**
@ -48,9 +60,15 @@ export interface Configuration {
*
* @type { ?ConfigurationConstant.Direction }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* Indicates the screen direction of the current device.
* @type { ConfigurationConstant.Direction }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
direction?: ConfigurationConstant.Direction;
/**

View File

@ -26,9 +26,15 @@ declare namespace ConfigurationConstant {
*
* @enum { number }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* ColorMode
* @enum { number }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
export enum ColorMode {
/**
* The color mode is not set.
@ -63,9 +69,15 @@ declare namespace ConfigurationConstant {
*
* @enum { number }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* Direction
* @enum { number }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
export enum Direction {
/**
* The direction is not set.

View File

@ -212,9 +212,15 @@ export interface Callee {
* @extends Ability
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* The class of a UI ability.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
export default class UIAbility extends Ability {
/**
* Indicates configuration information about an ability context.
@ -222,9 +228,16 @@ export default class UIAbility extends Ability {
* @type { UIAbilityContext }
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates configuration information about an ability context.
* @type { UIAbilityContext }
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
context: UIAbilityContext;
/**
@ -264,9 +277,17 @@ export default class UIAbility extends Ability {
* @param { AbilityConstant.LaunchParam } param - Indicates the launch param.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when an ability is started for initialization.
* @param { Want } want - Indicates the want info of the created ability.
* @param { AbilityConstant.LaunchParam } param - Indicates the launch param.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onCreate(want: Want, param: AbilityConstant.LaunchParam): void;
/**
@ -275,9 +296,16 @@ export default class UIAbility extends Ability {
* @param { window.WindowStage } windowStage - Indicates the created WindowStage.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when an ability window stage is created.
* @param { window.WindowStage } windowStage - Indicates the created WindowStage.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onWindowStageCreate(windowStage: window.WindowStage): void;
/**
@ -285,9 +313,15 @@ export default class UIAbility extends Ability {
*
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when an ability window stage is destroyed.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onWindowStageDestroy(): void;
/**
@ -306,9 +340,15 @@ export default class UIAbility extends Ability {
* @returns { void | Promise<void> } the promise returned by the function.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back before an ability is destroyed.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onDestroy(): void | Promise<void>;
/**
@ -316,9 +356,15 @@ export default class UIAbility extends Ability {
*
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when the state of an ability changes to foreground.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onForeground(): void;
/**
@ -326,9 +372,15 @@ export default class UIAbility extends Ability {
*
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called back when the state of an ability changes to background.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onBackground(): void;
/**
@ -350,9 +402,18 @@ export default class UIAbility extends Ability {
* @param { AbilityConstant.LaunchParam } launchParams - Indicates the launch parameters.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Called when the launch mode of an ability is set to singleton.
* This happens when you re-launch an ability that has been at the top of the ability stack.
* @param { Want } want - Indicates the want info of ability.
* @param { AbilityConstant.LaunchParam } launchParams - Indicates the launch parameters.
* @syscap SystemCapability.Ability.AbilityRuntime.AbilityCore
* @StageModelOnly
* @crossplatform
* @since 10
*/
onNewWant(want: Want, launchParams: AbilityConstant.LaunchParam): void;
/**

View File

@ -17,18 +17,28 @@
* Want is the basic communication component of the system.
*
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* Want is the basic communication component of the system.
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
export default class Want {
/**
* bundle name
*
* @type { ?string }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* bundle name
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
bundleName?: string;
/**
@ -36,9 +46,14 @@ export default class Want {
*
* @type { ?string }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* ability name
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
abilityName?: string;
/**
@ -91,9 +106,14 @@ export default class Want {
*
* @type { ?[key: string]: Object }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* The description of the WantParams object in an Want
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
parameters?: { [key: string]: Object };
/**
@ -110,8 +130,13 @@ export default class Want {
*
* @type { ?string }
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 9
*/
/**
* The description of an module name in an want.
* @syscap SystemCapability.Ability.AbilityBase
* @crossplatform
* @since 10
*/
moduleName?: string;
}

View File

@ -32,48 +32,77 @@ import { ConnectOptions as _ConnectOptions } from './ability/connectOptions';
* @namespace common
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* This module provides application context classes and common data structures.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
declare namespace common {
/**
* The context of an ability. It allows access to ability-specific resources.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
export type UIAbilityContext = _UIAbilityContext.default;
/**
* The context of an ability. It allows access to ability-specific resources.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export type UIAbilityContext = _UIAbilityContext.default
/**
* The context of an abilityStage. It allows access to abilityStage-specific resources.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
export type AbilityStageContext = _AbilityStageContext.default;
/**
* The context of an abilityStage. It allows access to abilityStage-specific resources.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export type AbilityStageContext = _AbilityStageContext.default
/**
* The context of an application. It allows access to application-specific resources.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
export type ApplicationContext = _ApplicationContext.default;
/**
* The context of an application. It allows access to application-specific resources.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export type ApplicationContext = _ApplicationContext.default
/**
* The base context of 'app.Context' for FA Mode or 'application.Context' for Stage Mode.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 9
*/
export type BaseContext = _BaseContext.default;
/**
* The base context of 'app.Context' for FA Mode or 'application.Context' for Stage Mode.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 10
*/
export type BaseContext = _BaseContext.default
/**
* The base context of an ability or an application. It allows access to
@ -81,10 +110,17 @@ declare namespace common {
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
export type Context = _Context.default;
/**
* The base context of an ability or an application. It allows access to
* application-specific resources.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export type Context = _Context.default
/**
* The context of an extension. It allows access to extension-specific resources.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-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
@ -13,60 +13,60 @@
* limitations under the License.
*/
import rpc from "./@ohos.rpc";
import WindowExtensionContext from "./application/WindowExtensionContext";
import rpc from './@ohos.rpc';
import WindowExtensionContext from './application/WindowExtensionContext';
import Want from './@ohos.app.ability.Want';
import window from './@ohos.window';
/**
* class of window extension ability.
*
* @since 9
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi hide for inner use.
* @StageModelOnly
* @since 9
*/
export default class WindowExtensionAbility {
/**
* Indicates window extension ability context.
*
* @since 9
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi hide for inner use.
* @StageModelOnly
* @since 9
*/
context: WindowExtensionContext;
/**
* Called back when a window extension is first connected to an ability.
*
* @since 9
* @param { Want } want Indicates connection information about the Window ability.
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @param want Indicates connection information about the Window ability.
* @systemapi hide for inner use.
* @StageModelOnly
* @since 9
*/
onConnect(want: Want): void;
/**
* Called back when all abilities connected to a window extension are disconnected.
*
* @since 9
* @param { Want } want Indicates disconnection information about the window extension.
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @param want Indicates disconnection information about the window extension.
* @systemapi hide for inner use.
* @StageModelOnly
* @since 9
*/
onDisconnect(want: Want): void;
/**
* Called back when window is created.
*
* @since 9
* @param { window.Window } window Current Window instance.
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi hide for inner use.
* @StageModelOnly
* @since 9
*/
onWindowReady(window: window.Window): void;
}

View File

@ -474,26 +474,45 @@ declare namespace bundleManager {
*
* @enum { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Launch type
*
* @enum { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
export enum LaunchType {
/**
* Indicates that the ability has only one instance
*
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates that the ability has only one instance
*
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
SINGLETON = 0,
/**
* Indicates that the ability can have multiple instances
*
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates that the ability can have multiple instances
*
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
MULTITON = 1,
/**
@ -518,6 +537,7 @@ declare namespace bundleManager {
* Indicates that the ability has a UI
*
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @FAModelOnly
* @since 9
*/
PAGE = 1,
@ -526,6 +546,7 @@ declare namespace bundleManager {
* Indicates that the ability does not have a UI
*
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @FAModelOnly
* @since 9
*/
SERVICE = 2,
@ -534,6 +555,7 @@ declare namespace bundleManager {
* Indicates that the ability is used to provide data access services
*
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @FAModelOnly
* @since 9
*/
DATA = 3

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,7 @@
*/
import { AsyncCallback } from './@ohos.base';
import type colorSpaceManager from './@ohos.graphics.colorSpaceManager.d.ts';
/**
* @namespace image
@ -1323,6 +1324,25 @@ declare namespace image {
*/
crop(region: Region): Promise<void>;
/**
* Get color space of pixel map.
*
* @returns { colorSpaceManager.ColorSpaceManager } If the operation fails, an error message is returned.
* @syscap SystemCapability.Multimedia.Image.Core
* @since 10
*/
getColorSpace(): colorSpaceManager.ColorSpaceManager;
/**
* Set color space of pixel map.
*
* @param { colorSpaceManager.ColorSpaceManager } colorSpace The color space for pixel map.
* @returns { void } If the operation fails, an error message is returned.
* @syscap SystemCapability.Multimedia.Image.Core
* @since 10
*/
setColorSpace(colorSpace: colorSpaceManager.ColorSpaceManager): void;
/**
* Releases this PixelMap object. This method uses a callback to return the result.
*

View File

@ -509,6 +509,7 @@ declare namespace pointer {
* @param { PrimaryButton } primary - Indicates mouse primary button. The value LEFT indicates that mouse primary
* button is left button, and the value RIGHT indicates that mouse primary button is right button.
* @param { AsyncCallback<void> } callback - Callback used to return the result.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -522,6 +523,7 @@ declare namespace pointer {
* @param { PrimaryButton } primary - Indicates mouse primary button. The value LEFT indicates that mouse primary
* button is left button, and the value RIGHT indicates that mouse primary button is right button.
* @returns { Promise<void> } Returns the result through a promise.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -533,6 +535,7 @@ declare namespace pointer {
* Gets mouse primary button.
*
* @param { AsyncCallback<PrimaryButton> } callback - Callback used to return the result.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -544,6 +547,7 @@ declare namespace pointer {
* Gets mouse primary button.
*
* @returns { Promise<PrimaryButton> } Returns the result through a promise.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -557,6 +561,7 @@ declare namespace pointer {
* @param { boolean } state - Indicates whether the mouse hover scroll is enabled in inactive window. The value true
* indicates that the mouse hover scroll is enabled, and the value false indicates the opposite.
* @param { AsyncCallback<void> } callback - Callback used to return the result.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -570,6 +575,7 @@ declare namespace pointer {
* @param { boolean } state - Indicates whether the mouse hover scroll is enabled in inactive window. The value true
* indicates that the mouse hover scroll is enabled, and the value false indicates the opposite.
* @returns { Promise<void> } Returns the result through a promise.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -581,6 +587,7 @@ declare namespace pointer {
* Gets a status whether the mouse hover scroll is enabled in inactive window.
*
* @param { AsyncCallback<boolean> } callback - Callback used to return the result.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -592,6 +599,7 @@ declare namespace pointer {
* Gets a status whether mouse hover scroll is enabled in inactive window.
*
* @returns { Promise<boolean> } Returns the result through a promise.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -604,6 +612,7 @@ declare namespace pointer {
*
* @param { number } rows - Indicates the number of mouse scrolling rows.
* @param { AsyncCallback<void> } callback - Callback used to return the result.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -616,6 +625,7 @@ declare namespace pointer {
*
* @param { number } rows - Indicates the number of mouse scrolling rows.
* @returns { Promise<void> } Returns the result through a promise.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -627,6 +637,7 @@ declare namespace pointer {
* Get the number of mouse scrolling rows.
*
* @param { AsyncCallback<number> } callback - Callback used to return the result.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.
@ -638,6 +649,7 @@ declare namespace pointer {
* Get the number of mouse scrolling rows.
*
* @returns { Promise<number> } Returns the result through a promise.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.Pointer
* @systemapi hide for inner use.

View File

@ -27,6 +27,7 @@ declare namespace shortKey {
* @param { string } businessKey - The key for business which should be applied to MMI.
* @param { number } delay - Duration of short key press which should be limited to 0-4000ms.
* @param { AsyncCallback<void> } callback - Callback used to return the result.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.ShortKey
* @systemapi hide for inner use
@ -39,6 +40,7 @@ declare namespace shortKey {
* @param { string } businessKey - The key for business which should be applied to MMI.
* @param { number } delay - Duration of short key press which should be limited to 0-4000ms.
* @returns { Promise<void> } Returns the result through a promise.
* @throws { BusinessError } 202 - SystemAPI permission error.
* @throws { BusinessError } 401 - Parameter error.
* @syscap SystemCapability.MultimodalInput.Input.ShortKey
* @systemapi hide for inner use

3
api/@ohos.rpc.d.ts vendored
View File

@ -2435,8 +2435,7 @@ declare namespace rpc {
/**
* Obtains the SendRequest call flag, which can be synchronous or asynchronous.
*
* @returns { number } Return {@code true} if the the SendRequest is called synchronously;
* return {@code false} if the the SendRequest is called asynchronously.
* @returns { number } Return whether the SendRequest is called synchronously or asynchronously.
* @syscap SystemCapability.Communication.IPC.Core
* @since 7
*/

386
api/@ohos.screen.d.ts vendored
View File

@ -1,58 +1,99 @@
/*
* 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.
*/
* Copyright (c) 2022-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
*
* 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 { AsyncCallback, Callback } from './@ohos.base';
/**
* Interface of screen manager
*
* @namespace screen
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
declare namespace screen {
/**
* Get all screen
* @throws {BusinessError} 1400001 - If display or screen is invalid
* Get all screen instances, then can get or set detail information.
*
* @param { AsyncCallback<Array<Screen>> } callback the callback of all screens info
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function getAllScreens(callback: AsyncCallback<Array<Screen>>): void;
/**
* Get all screen instances, then can get or set detail information.
*
* @returns { Promise<Array<Screen>> } the result of all screens info
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function getAllScreens(): Promise<Array<Screen>>;
/**
* Register the callback for screen changes.
* @param eventType: type of callback
* @throws {BusinessError} 401 - If param is invalid
*
* @param { 'connect' | 'disconnect' | 'change' } eventType the event of screen changes
* @param { Callback<number> } callback Callback used to return the screen ID
* @throws { BusinessError } 401 - If param is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function on(eventType: 'connect' | 'disconnect' | 'change', callback: Callback<number>): void;
/**
* Unregister the callback for screen changes.
* @param eventType: type of callback
* @throws {BusinessError} 401 - If param is invalid
*
* @param { 'connect' | 'disconnect' | 'change' } eventType the event of screen changes
* @param { Callback<number> } callback Callback used to return the screen ID
* @throws { BusinessError } 401 - If param is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function off(eventType: 'connect' | 'disconnect' | 'change', callback?: Callback<number>): void;
/**
* Make screens as expand-screen
* @throws {BusinessError} 401 - If param is invalid
* @throws {BusinessError} 1400001 - If display or screen is invalid
*
* @param { Array<ExpandOption> } options Parameters for expanding the screen
* @param { AsyncCallback<number> } callback callback used to return the group ID of the expanded screens
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function makeExpand(options: Array<ExpandOption>, callback: AsyncCallback<number>): void;
/**
* Make screens as expand-screen
*
* @param { Array<ExpandOption> } options Parameters for expanding the screen
* @returns { Promise<number> } used to return the group ID of the expanded screens
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function makeExpand(options: Array<ExpandOption>): Promise<number>;
/**
@ -83,11 +124,30 @@ declare namespace screen {
/**
* Make screens as mirror-screen
* @throws {BusinessError} 401 - If param is invalid
* @throws {BusinessError} 1400001 - If display or screen is invalid
*
* @param { number } mainScreen ID of the primary screen
* @param { Array<number> } mirrorScreen IDs of secondary screens
* @param { AsyncCallback<number> } callback Callback used to return the group ID of the secondary screens
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function makeMirror(mainScreen: number, mirrorScreen: Array<number>, callback: AsyncCallback<number>): void;
/**
* Make screens as mirror-screen
*
* @param { number } mainScreen ID of the primary screen
* @param { Array<number> } mirrorScreen IDs of secondary screens
* @returns { Promise<number> } Promise used to return the group ID of the secondary screens
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function makeMirror(mainScreen: number, mirrorScreen: Array<number>): Promise<number>;
/**
@ -118,201 +178,422 @@ declare namespace screen {
/**
* Create virtual screen. if surfaceId is valid, this permission is necessary.
* @param options Indicates the options of the virtual screen.
*
* @permission ohos.permission.CAPTURE_SCREEN
* @throws {BusinessError} 201 - If there is no permission
* @throws {BusinessError} 401 - If param is invalid
* @throws {BusinessError} 1400001 - If display or screen is invalid
* @param { VirtualScreenOption } options Indicates the options of the virtual screen.
* @param { AsyncCallback<Screen> } callback Callback used to return the created virtual screen
* @throws { BusinessError } 201 - If there is no permission
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function createVirtualScreen(options: VirtualScreenOption, callback: AsyncCallback<Screen>): void;
/**
* Create virtual screen. if surfaceId is valid, this permission is necessary.
*
* @permission ohos.permission.CAPTURE_SCREEN
* @param { VirtualScreenOption } options Indicates the options of the virtual screen.
* @returns { Promise<Screen> } Promise used to return the created virtual screen
* @throws { BusinessError } 201 - If there is no permission
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function createVirtualScreen(options: VirtualScreenOption): Promise<Screen>;
/**
* Destroy virtual screen.
* @param screenId Indicates the screen id of the virtual screen.
* @throws {BusinessError} 401 - If param is invalid
* @throws {BusinessError} 1400002 - If operation other screen
*
* @param { number } screenId Indicates the screen id of the virtual screen.
* @param { AsyncCallback<void> } callback Callback used to return the result.
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400002 - If operation other screen
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function destroyVirtualScreen(screenId: number, callback: AsyncCallback<void>): void;
/**
* Destroy virtual screen.
*
* @param { number } screenId Indicates the screen id of the virtual screen.
* @returns { Promise<void> } Promise that returns no value.
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400002 - If operation other screen
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function destroyVirtualScreen(screenId: number): Promise<void>;
/**
* Set surface for the virtual screen.
* @param screenId Indicates the screen id of the virtual screen.
* @param surfaceId Indicates the surface id.
*
* @permission ohos.permission.CAPTURE_SCREEN
* @throws {BusinessError} 201 - If there is no permission
* @throws {BusinessError} 401 - If param is invalid
* @throws {BusinessError} 1400001 - If display or screen is invalid
* @param { number } screenId Indicates the screen id of the virtual screen.
* @param { string } surfaceId Indicates the surface id.
* @param { AsyncCallback<void> } callback Callback used to return the result
* @throws { BusinessError } 201 - If there is no permission
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function setVirtualScreenSurface(screenId: number, surfaceId: string, callback: AsyncCallback<void>): void;
/**
* Set surface for the virtual screen.
*
* @permission ohos.permission.CAPTURE_SCREEN
* @param { number } screenId Indicates the screen id of the virtual screen.
* @param { string } surfaceId Indicates the surface id.
* @returns { Promise<void> } Promise that returns no value
* @throws { BusinessError } 201 - If there is no permission
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400001 - If display or screen is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function setVirtualScreenSurface(screenId: number, surfaceId: string): Promise<void>;
/**
* Get screen rotation lock status.
*
* @param { AsyncCallback<boolean> } callback If true, auto rotate is locked. If false, auto rotate is unlocked
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function isScreenRotationLocked(callback: AsyncCallback<boolean>): void;
/**
* Get screen rotation lock status.
*
* @returns { Promise<boolean> } If true, auto rotate is locked. If false, auto rotate is unlocked
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function isScreenRotationLocked(): Promise<boolean>;
/**
* Set screen rotation lock status.
* @param isLocked Indicates whether the screen rotation switch is locked.
* @throws {BusinessError} 401 - If param is invalid
*
* @param { boolean } isLocked Indicates whether the screen rotation switch is locked.
* @param { AsyncCallback<void> } callback Callback used to return the result.
* @throws { BusinessError } 401 - If param is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function setScreenRotationLocked(isLocked: boolean, callback: AsyncCallback<void>): void;
/**
* Set screen rotation lock status.
*
* @param { boolean } isLocked Indicates whether the screen rotation switch is locked.
* @returns { Promise<void> } Promise that returns no value.
* @throws { BusinessError } 401 - If param is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
function setScreenRotationLocked(isLocked: boolean): Promise<void>;
/**
* The parameter of making expand screen
*
* @interface ExpandOption
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
interface ExpandOption {
/**
* Screen id
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
screenId: number;
/**
* The start coordinate X of the screen origin
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
startX: number;
/**
* The start coordinate Y of the screen origin
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
startY: number;
}
/**
* The parameter for creating virtual screen.
*
* @interface VirtualScreenOption
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
interface VirtualScreenOption {
/**
* Indicates the name of the virtual screen.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
name: string
name: string;
/**
* Indicates the width of the virtual screen.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
width: number
width: number;
/**
* Indicates the height of the virtual screen.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
height: number
height: number;
/**
* Indicates the density of the virtual screen.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
density: number
density: number;
/**
* Indicates the surface id of the virtual screen.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
surfaceId: string
surfaceId: string;
}
/**
* Indicate the source mode of the screen
*
* @enum { number }
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
enum ScreenSourceMode {
/**
* Indicate that the screen is the default screen.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
SCREEN_MAIN = 0,
/**
* Indicate that the screen is in mirror mode.
* Indicate that the screen is in mirror mode.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
SCREEN_MIRROR = 1,
/**
* Indicate that the screen is in extend mode.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
SCREEN_EXTEND = 2,
/**
* Indicate that the screen stands alone.
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
SCREEN_ALONE = 3,
SCREEN_ALONE = 3
}
/**
* Interface for screen
*
* @interface Screen
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
interface Screen {
/**
* Screen id
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
readonly id: number;
/**
* Group id
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
readonly parent: number;
/**
* Mode supported by the screen
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
readonly supportedModeInfo: Array<ScreenModeInfo>;
/**
* Currently active mode
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
readonly activeModeIndex: number;
/**
* Orientation of the screen
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
readonly orientation: Orientation;
/**
* Source mode of the screen
*
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 10
*/
readonly sourceMode: ScreenSourceMode;
/**
* Set the orientation of the screen
* @throws {BusinessError} 401 - If param is invalid
* @throws {BusinessError} 1400003 - If system state is abnormally
*
* @param { Orientation } orientation Screen orientation.
* @param { AsyncCallback<void> } callback Callback used to return the result.
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400003 - If system state is abnormally
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
setOrientation(orientation: Orientation, callback: AsyncCallback<void>): void;
/**
* Set the orientation of the screen
*
* @param { Orientation } orientation Screen orientation.
* @returns { Promise<void> } Promise that returns no value.
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400003 - If system state is abnormally
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
setOrientation(orientation: Orientation): Promise<void>;
/**
* Active the mode
* @throws {BusinessError} 401 - If param is invalid
* @throws {BusinessError} 1400003 - If system state is abnormally
*
* @param { number } modeIndex Index of the mode to set.
* @param { AsyncCallback<void> } callback Callback used to return the result.
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400003 - If system state is abnormally
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
setScreenActiveMode(modeIndex: number, callback: AsyncCallback<void>): void;
/**
* Active the mode
*
* @param { number } modeIndex Index of the mode to set.
* @returns { Promise<void> } Promise that returns no value.
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400003 - If system state is abnormally
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
setScreenActiveMode(modeIndex: number): Promise<void>;
/**
* Set display density of the screen
* @throws {BusinessError} 401 - If param is invalid
* @throws {BusinessError} 1400003 - If system state is abnormally
*
* @param { number } densityDpi Pixel density. The value ranges from 80 to 640.
* @param { AsyncCallback<void> } callback Callback used to return the result.
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400003 - If system state is abnormally
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
setDensityDpi(densityDpi: number, callback: AsyncCallback<void>): void;
/**
* Set display density of the screen
*
* @param { number } densityDpi Pixel density. The value ranges from 80 to 640.
* @returns { Promise<void> } Promise that returns no value.
* @throws { BusinessError } 401 - If param is invalid
* @throws { BusinessError } 1400003 - If system state is abnormally
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
setDensityDpi(densityDpi: number): Promise<void>;
}
/**
* Screen orientation
*
* @enum { number }
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
enum Orientation {
@ -320,12 +601,15 @@ declare namespace screen {
VERTICAL = 1,
HORIZONTAL = 2,
REVERSE_VERTICAL = 3,
REVERSE_HORIZONTAL = 4,
REVERSE_HORIZONTAL = 4
}
/**
* The information of the screen
*
* @interface ScreenModeInfo
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
* @since 9
*/
interface ScreenModeInfo {

File diff suppressed because it is too large Load Diff

View File

@ -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
@ -18,57 +18,107 @@ import { AsyncCallback } from "./@ohos.base";
/**
* Provides methods related to cellular data services.
*
* @since 7
* @namespace data
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
declare namespace data {
/**
* Get the default cellular data card.
*
* @returns Returns default cellular data slot id.
* @param { AsyncCallback<number> } callback - Indicates the default cellular data slot id.
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function getDefaultCellularDataSlotId(callback: AsyncCallback<number>): void;
/**
* Get the default cellular data card.
*
* @returns { Promise<number> } Returns the default cellular data slot id.
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function getDefaultCellularDataSlotId(): Promise<number>;
/**
* Get the default cellular data card.
*
* @returns Returns default cellular data slot id.
* @returns { number } Returns default cellular data slot id.
* @syscap SystemCapability.Telephony.CellularData
* @since 9
*/
function getDefaultCellularDataSlotIdSync(): number;
/**
* Switches cellular data services to another card, without changing the default settings.
* Switch cellular data services to another card, without changing the default settings.
*
* @param slotId Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @permission ohos.permission.SET_TELEPHONY_STATE
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300004 - Do not have sim card.
* @throws {BusinessError} 8300999 - Unknown error code.
* @throws {BusinessError} 8301001 - SIM card is not activated.
* @param { number } slotId - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { AsyncCallback<void> } callback - The callback of setDefaultCellularDataSlotId.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300004 - Do not have sim card.
* @throws { BusinessError } 8300999 - Unknown error code.
* @throws { BusinessError } 8301001 - SIM card is not activated.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function setDefaultCellularDataSlotId(slotId: number, callback: AsyncCallback<void>): void;
/**
* Switch cellular data services to another card, without changing the default settings.
*
* @permission ohos.permission.SET_TELEPHONY_STATE
* @param { number } slotId - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @returns { Promise<void> } The promise returned by the setDefaultCellularDataSlotId.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300004 - Do not have sim card.
* @throws { BusinessError } 8300999 - Unknown error code.
* @throws { BusinessError } 8301001 - SIM card is not activated.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function setDefaultCellularDataSlotId(slotId: number): Promise<void>;
/**
* Indicates that there is no uplink or downlink data.
*
* <p>It is a return value of service state query of cellular data services.
* @param { AsyncCallback<DataFlowType> } callback - Indicates the data flow type.
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function getCellularDataFlowType(callback: AsyncCallback<DataFlowType>): void;
/**
* Indicates that there is no uplink or downlink data.
*
* <p>It is a return value of service state query of cellular data services.
* @returns { Promise<DataFlowType> } Returns the data flow type.
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function getCellularDataFlowType(): Promise<DataFlowType>;
/**
* Obtains the connection state of the PS domain.
* Obtain the connection state of the PS domain.
*
* @param callback Returns the connection state, which can be any of the following:
* @param { AsyncCallback<DataConnectState> } callback - Indicates the callback for getting the connection state,
* which can be any of the following:
* <ul>
* <li>{@code DataConnectState#DATA_STATE_UNKNOWN}
* <li>{@code DataConnectState#DATA_STATE_DISCONNECTED}
@ -76,162 +126,340 @@ declare namespace data {
* <li>{@code DataConnectState#DATA_STATE_CONNECTED}
* <li>{@code DataConnectState#DATA_STATE_SUSPENDED}
* </ul>
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function getCellularDataState(callback: AsyncCallback<DataConnectState>): void;
/**
* Obtain the connection state of the PS domain.
*
* @returns { Promise<DataConnectState> } Returns the connection state, which can be any of the following:
* <ul>
* <li>{@code DataConnectState#DATA_STATE_UNKNOWN}
* <li>{@code DataConnectState#DATA_STATE_DISCONNECTED}
* <li>{@code DataConnectState#DATA_STATE_CONNECTING}
* <li>{@code DataConnectState#DATA_STATE_CONNECTED}
* <li>{@code DataConnectState#DATA_STATE_SUSPENDED}
* </ul>
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function getCellularDataState(): Promise<DataConnectState>;
/**
* Checks whether cellular data services are enabled.
* Check whether cellular data services are enabled.
*
* @param callback Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise.
* @permission ohos.permission.GET_NETWORK_INFO
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { AsyncCallback<boolean> } callback - Indicates the callback for checking whether cellular data services
* are enabled. Returns {@code true} if cellular data services are enabled; returns {@code false} otherwise.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function isCellularDataEnabled(callback: AsyncCallback<boolean>): void;
/**
* Check whether cellular data services are enabled.
*
* @permission ohos.permission.GET_NETWORK_INFO
* @returns { Promise<boolean> } Returns {@code true} if cellular data services are enabled.
* Returns {@code false} otherwise.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function isCellularDataEnabled(): Promise<boolean>;
/**
* Enables cellular data services.
* Enable cellular data services.
*
* @permission ohos.permission.SET_TELEPHONY_STATE
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { AsyncCallback<void> } callback - The callback of enableCellularData.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function enableCellularData(callback: AsyncCallback<void>): void;
/**
* Enable cellular data services.
*
* @permission ohos.permission.SET_TELEPHONY_STATE
* @returns { Promise<void> } The promise returned by the enableCellularData.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function enableCellularData(): Promise<void>;
/**
* Disables cellular data services.
* Disable cellular data services.
*
* @permission ohos.permission.SET_TELEPHONY_STATE
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { AsyncCallback<void> } callback - The callback of disableCellularData.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function disableCellularData(callback: AsyncCallback<void>): void;
/**
* Disable cellular data services.
*
* @permission ohos.permission.SET_TELEPHONY_STATE
* @returns { Promise<void> } The promise returned by the disableCellularData.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function disableCellularData(): Promise<void>;
/**
* Checks whether roaming is enabled for cellular data services.
* Check whether roaming is enabled for cellular data services.
*
* @param slotId Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param callback Returns {@code true} if roaming is enabled for cellular data services; returns {@code false} otherwise.
* @permission ohos.permission.GET_NETWORK_INFO
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { number } slotId - Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { AsyncCallback<boolean> } callback - Indicates the callback for checking whether roaming is enabled
* for cellular data services. Returns {@code true} if roaming is enabled for cellular data services;
* returns {@code false} otherwise.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function isCellularDataRoamingEnabled(slotId: number, callback: AsyncCallback<boolean>): void;
/**
* Check whether roaming is enabled for cellular data services.
*
* @permission ohos.permission.GET_NETWORK_INFO
* @param { number } slotId - Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @returns { Promise<boolean> } Returns {@code true} if roaming is enabled for cellular data services.
* Returns {@code false} otherwise.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
function isCellularDataRoamingEnabled(slotId: number): Promise<boolean>;
/**
* Enables cellular data roaming.
* Enable cellular data roaming.
*
* @param slotId Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @permission ohos.permission.SET_TELEPHONY_STATE
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { number } slotId - Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { AsyncCallback<void> } callback - The callback of enableCellularDataRoaming.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function enableCellularDataRoaming(slotId: number, callback: AsyncCallback<void>): void;
/**
* Enable cellular data roaming.
*
* @permission ohos.permission.SET_TELEPHONY_STATE
* @param { number } slotId - Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @returns { Promise<void> } The promise returned by the enableCellularDataRoaming.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function enableCellularDataRoaming(slotId: number): Promise<void>;
/**
* Disables cellular data roaming.
* Disable cellular data roaming.
*
* @param slotId Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @permission ohos.permission.SET_TELEPHONY_STATE
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { number } slotId - Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { AsyncCallback<void> } callback - The callback of disableCellularDataRoaming.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function disableCellularDataRoaming(slotId: number, callback: AsyncCallback<void>): void;
/**
* Disable cellular data roaming.
*
* @permission ohos.permission.SET_TELEPHONY_STATE
* @param { number } slotId - Indicates the ID of a card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @returns { Promise<void> } The promise returned by the disableCellularDataRoaming.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.CellularData
* @systemapi Hide this for inner system use.
* @since 7
*/
function disableCellularDataRoaming(slotId: number): Promise<void>;
/**
* Describes the cellular data flow type.
*
* @enum { number }
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
export enum DataFlowType {
/**
* Indicates that there is no uplink or downlink data.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_FLOW_TYPE_NONE = 0,
/**
* Indicates that there is only downlink data.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_FLOW_TYPE_DOWN = 1,
/**
* Indicates that there is only uplink data.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_FLOW_TYPE_UP = 2,
/**
* Indicates that there is uplink and downlink data.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_FLOW_TYPE_UP_DOWN = 3,
/**
* Indicates that there is no uplink or downlink data, and the bottom-layer link is in the dormant state.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_FLOW_TYPE_DORMANT = 4
}
/**
* Describes the cellular data link connection state.
*
* @enum { number }
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
export enum DataConnectState {
/**
* Indicates that a cellular data link is unknown.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_STATE_UNKNOWN = -1,
/**
* Indicates that a cellular data link is disconnected.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_STATE_DISCONNECTED = 0,
/**
* Indicates that a cellular data link is being connected.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_STATE_CONNECTING = 1,
/**
* Indicates that a cellular data link is connected.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_STATE_CONNECTED = 2,
/**
* Indicates that a cellular data link is suspended.
*
* @syscap SystemCapability.Telephony.CellularData
* @since 7
*/
DATA_STATE_SUSPENDED = 3
}

View File

@ -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,8 +23,9 @@ import sim from "./@ohos.telephony.sim";
* Monitors telephony state updates of a device, including updates of the network state,
* signal strength, call state, the data link connection state and others.
*
* @since 6
* @namespace observer
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
declare namespace observer {
type NetworkState = radio.NetworkState;
@ -41,265 +42,517 @@ declare namespace observer {
type SimState = sim.SimState;
/**
* Called when the network state corresponding to a monitored {@code slotId} updates.
* Callback when the network state corresponding to the default sim card is updated.
*
* @param type networkStateChange
* @param options including slotId Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param callback including an instance of the {@code NetworkState} class.
* @permission ohos.permission.GET_NETWORK_INFO
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - networkStateChange.
* @param { Callback<NetworkState> } callback - Indicates the callback for
* getting an instance of the {@code NetworkState} class.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function on(type: 'networkStateChange', callback: Callback<NetworkState>): void;
/**
* Callback when the network state corresponding to the monitored {@code slotId} is updated.
*
* @permission ohos.permission.GET_NETWORK_INFO
* @param { string } type - networkStateChange.
* @param { { slotId: number } } options - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { Callback<NetworkState> } callback - Indicates the callback for getting
* an instance of the {@code NetworkState} class.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function on(type: 'networkStateChange', options: { slotId: number }, callback: Callback<NetworkState>): void;
/**
* Cancel Called when the network state corresponding to a monitored {@code slotId} updates.
* Cancel callback when the network state is updated.
*
* @param type networkStateChange
* @param callback including an instance of the {@code NetworkState} class.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - networkStateChange.
* @param { Callback<NetworkState> } callback - Indicates the callback to unsubscribe from the networkStateChange event.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function off(type: 'networkStateChange', callback?: Callback<NetworkState>): void;
/**
* Called when the signal strength corresponding to a monitored {@code slotId} updates.
* Callback when the signal strength corresponding to the default sim card is updated.
*
* @param type signalInfoChange
* @param options including slotId Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param callback including an array of instances of the classes derived from {@link SignalInformation}.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - signalInfoChange.
* @param { Callback<Array<SignalInformation>> } callback - Indicates the callback for getting
* an array of instances of the classes derived from {@link SignalInformation}.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function on(type: 'signalInfoChange', callback: Callback<Array<SignalInformation>>): void;
function on(type: 'signalInfoChange', options: { slotId: number },
callback: Callback<Array<SignalInformation>>): void;
/**
* Cancel Called when the signal strength corresponding to a monitored {@code slotId} updates.
* Callback when the signal strength corresponding to a monitored {@code slotId} is updated.
*
* @param type signalInfoChange
* @param callback including an array of instances of the classes derived from {@link SignalInformation}.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - signalInfoChange.
* @param { { slotId: number } } options - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { Callback<Array<SignalInformation>> } callback - Indicates the callback for getting
* an array of instances of the classes derived from {@link SignalInformation}.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function on(type: 'signalInfoChange', options: { slotId: number }, callback: Callback<Array<SignalInformation>>): void;
/**
* Cancel callback when the signal strength is updated.
*
* @param { string } type - signalInfoChange.
* @param { Callback<SignalInformation> } callback - Indicates the callback to unsubscribe from
* the signalInfoChange event.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function off(type: 'signalInfoChange', callback?: Callback<Array<SignalInformation>>): void;
/**
* Called back when the cell information corresponding to a monitored {@code slotId} updates.
* Callback when the cell information corresponding to the default sim card is updated.
*
* @param type cellInfoChange
* @param options including slotId Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param callback including an array of instances of the classes derived from {@link CellInformation}.
* @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
* @throws {BusinessError} 201 - Permission denied.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - cellInfoChange.
* @param { Callback<Array<CellInformation>> } callback - Indicates the callback for getting
* an array of instances of the classes derived from {@link CellInformation}.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @systemapi Hide this for inner system use.
* @since 8
*/
function on(type: 'cellInfoChange', callback: Callback<Array<CellInformation>>): void;
function on(type: 'cellInfoChange', options: { slotId: number },
callback: Callback<Array<CellInformation>>): void;
/**
* Cancel Called back when the cell information corresponding to a monitored {@code slotId} updates.
* Callback when the cell information corresponding to a monitored {@code slotId} is updated.
*
* @param type cellInfoChange
* @param callback including an array of instances of the classes derived from {@link CellInformation}.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @permission ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
* @param { string } type - cellInfoChange.
* @param { { slotId: number } } options - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { Callback<Array<CellInformation>> } callback - Indicates the callback for getting
* an array of instances of the classes derived from {@link CellInformation}.
* @throws { BusinessError } 201 - Permission denied.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @systemapi Hide this for inner system use.
* @since 8
*/
function on(type: 'cellInfoChange', options: { slotId: number }, callback: Callback<Array<CellInformation>>): void;
/**
* Cancel callback when the cell information is updated.
*
* @param { string } type - cellInfoChange.
* @param { Callback<Array<CellInformation>> } callback - Indicates the callback to unsubscribe from
* the cellInfoChange event.
* @throws { BusinessError } 202 - Non-system applications use system APIs.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @systemapi Hide this for inner system use.
* @since 8
*/
function off(type: 'cellInfoChange', callback?: Callback<Array<CellInformation>>): void;
/**
* Called when the cellular data link connection state updates.
* Callback when the cellular data link connection state corresponding to the default sim card is updated.
*
* @param type cellularDataConnectionStateChange
* @param options including slotId Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param callback including state Indicates the cellular data link connection state,
* and networkType Indicates the radio access technology for cellular data services.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - cellularDataConnectionStateChange.
* @param { Callback<{ state: DataConnectState, network: RatType }> } callback - Indicates the callback for
* getting the cellular data link connection state, and networkType Indicates the radio access technology
* for cellular data services.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function on(type: 'cellularDataConnectionStateChange',
callback: Callback<{ state: DataConnectState, network: RatType }>): void;
/**
* Callback when the cellular data link connection state corresponding to the monitored {@code slotId} is updated.
*
* @param { string } type - cellularDataConnectionStateChange.
* @param { { slotId: number } } options - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { Callback<{ state: DataConnectState, network: RatType }> } callback - Indicates the callback for
* getting the cellular data link connection state, and networkType Indicates the radio access technology for
* cellular data services.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function on(type: 'cellularDataConnectionStateChange', options: { slotId: number },
callback: Callback<{ state: DataConnectState, network: RatType }>): void;
/**
* Cancel Called when the cellular data link connection state updates.
* Cancel callback when the cellular data link connection state is updated.
*
* @param type cellularDataConnectionStateChange
* @param callback including state Indicates the cellular data link connection state,
* and networkType Indicates the radio access technology for cellular data services.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - cellularDataConnectionStateChange.
* @param { Callback<{ state: DataConnectState, network: RatType }> } callback - Indicates the callback to unsubscribe
* from the cellularDataConnectionStateChange event.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function off(type: 'cellularDataConnectionStateChange',
callback?: Callback<{ state: DataConnectState, network: RatType }>): void;
/**
* Called when the uplink and downlink data flow state of cellular data services updates.
* Callback when the uplink and downlink data flow state of cellular data services
* corresponding to the default sim card is updated.
*
* @param type cellularDataFlowChange
* @param options including slotId Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param callback including the cellular data flow state.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - cellularDataFlowChange.
* @param { Callback<DataFlowType> } callback - Indicates the callback for getting the cellular data flow state.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function on(type: 'cellularDataFlowChange', callback: Callback<DataFlowType>): void;
function on(type: 'cellularDataFlowChange', options: { slotId: number },
callback: Callback<DataFlowType>): void;
/**
* Cancel Called when the uplink and downlink data flow state of cellular data services updates.
* Callback when the uplink and downlink data flow state of cellular data services
* corresponding to the monitored {@code slotId} is updated.
*
* @param type cellularDataFlowChange
* @param callback including the cellular data flow state.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - cellularDataFlowChange.
* @param { { slotId: number } } options - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { Callback<DataFlowType> } callback - Indicates the callback for getting the cellular data flow state.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function on(type: 'cellularDataFlowChange', options: { slotId: number }, callback: Callback<DataFlowType>): void;
/**
* Cancel callback when the uplink and downlink data flow state of cellular data services is updated.
*
* @param { string } type - cellularDataFlowChange.
* @param { Callback<DataFlowType> } callback - Indicates the callback to unsubscribe from
* the cellularDataFlowChange event.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function off(type: 'cellularDataFlowChange', callback?: Callback<DataFlowType>): void;
/**
* Receives a call state change. This callback is invoked when the call state of a specified card updates
* and the observer is added to monitor the updates.
* Callback when the call state corresponding to the default sim card is updated.
*
* @param type callStateChange
* @param options including slotId Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param callback including state Indicates the call state, and number Indicates the called number.
* The value of number is an empty string if the application does not have the
* ohos.permission.READ_CALL_LOG permission.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - callStateChange.
* @param { Callback<{ state: CallState, number: string }> } callback - Indicates the callback for
* getting the call state and the called number.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function on(type: 'callStateChange', callback: Callback<{ state: CallState, number: string }>): void;
function on(type: 'callStateChange', options: { slotId: number },
callback: Callback<{ state: CallState, number: string }>): void;
/**
* Cancel Receives a call state change. This callback is invoked when the call state of a specified card updates
* and the observer is added to monitor the updates.
* Callback when the call state corresponding to the monitored {@code slotId} is updated.
*
* @param type callStateChange
* @param callback including state Indicates the call state, and number Indicates the called number.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - callStateChange.
* @param { { slotId: number } } options - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { Callback<{ state: CallState, number: string }> } callback - Indicates the callback for
* getting the call state and the called number.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function on(type: 'callStateChange', options: { slotId: number }, callback: Callback<{ state: CallState, number: string }>): void;
/**
* Cancel callback when the call state is updated.
*
* @param { string } type - callStateChange.
* @param { Callback<{ state: CallState, number: string }> } callback - Indicates the callback to
* unsubscribe from the callStateChange event.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 6
*/
function off(type: 'callStateChange', callback?: Callback<{ state: CallState, number: string }>): void;
/**
* Receives a sim state change. This callback is invoked when the sim state of a specified card updates
* and the observer is added to monitor the updates.
* Callback when the sim state corresponding to the default sim card is updated.
*
* @param type simStateChange
* @param options including slotId Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param callback including state Indicates the sim state, and reason Indicates the cause of the change.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - simStateChange.
* @param { Callback<SimStateData> } callback - Indicates the callback for getting the SimStateData object.
* including state Indicates the sim state, and reason Indicates the cause of the change.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function on(type: 'simStateChange', callback: Callback<SimStateData>): void;
/**
* Callback when the sim state corresponding to the monitored {@code slotId} is updated.
*
* @param { string } type - simStateChange.
* @param { { slotId: number } } options - Indicates the ID of the target card slot.
* The value {@code 0} indicates card 1, and the value {@code 1} indicates card 2.
* @param { Callback<SimStateData> } callback - Indicates the callback for getting the SimStateData object.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function on(type: 'simStateChange', options: { slotId: number }, callback: Callback<SimStateData>): void;
/**
* Receives a sim state change. This callback is invoked when the sim state of a specified card updates
* and the observer is delete.
* Cancel callback when the sim state is updated.
*
* @param type simStateChange
* @param callback including state Indicates the sim state, and reason Indicates the cause of the change.
* @throws {BusinessError} 401 - Parameter error.
* @throws {BusinessError} 8300001 - Invalid parameter value.
* @throws {BusinessError} 8300002 - Operation failed. Cannot connect to service.
* @throws {BusinessError} 8300003 - System internal error.
* @throws {BusinessError} 8300999 - Unknown error code.
* @param { string } type - simStateChange.
* @param { Callback<SimStateData> } callback - Indicates the callback to unsubscribe from the simStateChange event.
* @throws { BusinessError } 401 - Parameter error.
* @throws { BusinessError } 8300001 - Invalid parameter value.
* @throws { BusinessError } 8300002 - Operation failed. Cannot connect to service.
* @throws { BusinessError } 8300003 - System internal error.
* @throws { BusinessError } 8300999 - Unknown error code.
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
function off(type: 'simStateChange', callback?: Callback<SimStateData>): void;
/**
* Indicates SIM card type and status.
*
* @interface SimStateData
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
export interface SimStateData {
type: CardType;
state: SimState;
/**
* Indicates the SIM card type.
*
* @type { CardType }
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
type: CardType;
/**
* Indicates the SIM card states.
*
* @type { SimState }
* @syscap SystemCapability.Telephony.StateRegistry
* @since 7
*/
state: SimState;
/**
* Indicates the SIM card lock type.
*
* @type { LockReason }
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
reason: LockReason;
}
/**
* Enum for SIM card lock type.
*
* @enum { number }
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
export enum LockReason {
/**
* Indicates no SIM lock.
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_NONE,
/**
* Indicates the PIN lock.
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PIN,
/**
* Indicates the PUK lock.
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PUK,
SIM_PN_PIN, //Network Personalization (refer 3GPP TS 22.022 [33])
/**
* Indicates network personalization of PIN lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PN_PIN,
/**
* Indicates network personalization of PUK lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PN_PUK,
SIM_PU_PIN, //Network Subset Personalization (refer 3GPP TS 22.022 [33])
/**
* Indicates network subset personalization of PIN lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PU_PIN,
/**
* Indicates network subset personalization of PUK lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PU_PUK,
SIM_PP_PIN, //Service Provider Personalization (refer 3GPP TS 22.022 [33])
/**
* Indicates service provider personalization of PIN lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PP_PIN,
/**
* Indicates service provider personalization of PUK lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PP_PUK,
SIM_PC_PIN, //Corporate Personalization (refer 3GPP TS 22.022 [33])
/**
* Indicates corporate personalization of PIN lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PC_PIN,
/**
* Indicates corporate personalization of PUK lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_PC_PUK,
SIM_SIM_PIN, //SIM/USIM Personalization (refer 3GPP TS 22.022 [33])
/**
* Indicates SIM/USIM personalization of PIN lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_SIM_PIN,
/**
* Indicates SIM/USIM personalization of PUK lock(refer 3GPP TS 22.022 [33]).
*
* @syscap SystemCapability.Telephony.StateRegistry
* @since 8
*/
SIM_SIM_PUK,
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -36,7 +36,7 @@ declare namespace usbManager {
* @param { USBDevice } device - USB device on the device list returned by getDevices().
* @returns { Readonly<USBDevicePipe> } object for data transfer.
* @throws { BusinessError } 401 - The parameter types do not match or parameter is not specified.
* @throws { BusinessError } 14400001 - USB Device access denied.
* @throws { BusinessError } 14400001 - Permission denied. Need call requestRight to get permission.
* @syscap SystemCapability.USB.USBManager
* @since 9
*/

View File

@ -1196,8 +1196,8 @@ declare namespace window {
/**
* Register the callback of systemBarTintChange
*
* @param { 'systemBarTintChange' } type - The value is fixed at 'systemBarTintChange', indicating the property change event of the status bar and navigation bar.
* @param { Callback<SystemBarTintState> } callback - Callback used to return the properties of the status bar and navigation bar.
* @param { 'systemBarTintChange' } type - The value is fixed at 'systemBarTintChange', indicating the property change event of the system bar.
* @param { Callback<SystemBarTintState> } callback - Callback used to return the properties of the system bar.
* @throws { BusinessError } 401 - If param is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.
@ -1208,8 +1208,8 @@ declare namespace window {
/**
* Unregister the callback of systemBarTintChange
*
* @param { 'systemBarTintChange' } type - The value is fixed at 'systemBarTintChange', indicating the property change event of the status bar and navigation bar.
* @param { Callback<SystemBarTintState> } callback - Callback used to return the properties of the status bar and navigation bar.
* @param { 'systemBarTintChange' } type - The value is fixed at 'systemBarTintChange', indicating the property change event of the system bar.
* @param { Callback<SystemBarTintState> } callback - Callback used to return the properties of the system bar.
* @throws { BusinessError } 401 - If param is invalid
* @syscap SystemCapability.WindowManager.WindowManager.Core
* @systemapi Hide this for inner system use.

View File

@ -23,6 +23,14 @@ import Context from './Context';
* @extends Context
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
*/
/**
* The context of an abilityStage. It allows access to abilityStage-specific resources.
*
* @since 10
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @permission N/A
* @StageModelOnly
* @crossplatform
* @since 9
*/
@ -32,6 +40,13 @@ export default class AbilityStageContext extends Context {
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
*/
/**
* Indicates configuration information about an module.
*
* @since 10
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
@ -42,6 +57,13 @@ export default class AbilityStageContext extends Context {
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
*/
/**
* Indicates configuration information.
*
* @since 10
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/

View File

@ -25,9 +25,15 @@ import { ProcessInformation } from './ProcessInformation';
* @extends Context
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* The context of an application. It allows access to application-specific resources.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export default class ApplicationContext extends Context {
/**
* Register ability lifecycle callback.
@ -38,10 +44,20 @@ export default class ApplicationContext extends Context {
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
on(type: 'abilityLifecycle', callback: AbilityLifecycleCallback): number;
/**
* Register ability lifecycle callback.
* @param { string } type - abilityLifecycle.
* @param { AbilityLifecycleCallback } callback - The ability lifecycle callback.
* @returns { number } Returns the number code of the callback.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
on(type: "abilityLifecycle", callback: AbilityLifecycleCallback): number;
/**
* Unregister ability lifecycle callback.
@ -52,10 +68,20 @@ export default class ApplicationContext extends Context {
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
off(type: 'abilityLifecycle', callbackId: number, callback: AsyncCallback<void>): void;
/**
* Unregister ability lifecycle callback.
* @param { string } type - abilityLifecycle.
* @param { number } callbackId - Indicates the number code of the callback.
* @param { AsyncCallback<void> } callback - The callback of off.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
off(type: "abilityLifecycle", callbackId: number, callback: AsyncCallback<void>): void;
/**
* Unregister ability lifecycle callback.
@ -118,9 +144,19 @@ export default class ApplicationContext extends Context {
* @throws { BusinessError } 16000050 - Internal error.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Get information about running processes
* @returns { Promise<Array<ProcessInformation>> } Returns the array of {@link ProcessInformation}.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @throws { BusinessError } 16000011 - The context does not exist.
* @throws { BusinessError } 16000050 - Internal error.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
getRunningProcessInformation(): Promise<Array<ProcessInformation>>;
/**
@ -132,9 +168,19 @@ export default class ApplicationContext extends Context {
* @throws { BusinessError } 16000050 - Internal error.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Get information about running processes
* @param { AsyncCallback<Array<ProcessInformation>> } callback - The callback is used to return the array of {@link ProcessInformation}.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @throws { BusinessError } 16000011 - The context does not exist.
* @throws { BusinessError } 16000050 - Internal error.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
getRunningProcessInformation(callback: AsyncCallback<Array<ProcessInformation>>): void;
/**

View File

@ -16,16 +16,30 @@
/**
* The base context of 'app.Context' for FA Mode or
* 'application.Context' for Stage Mode.
*
* @permission N/A
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 8
*/
/**
* The base context of 'app.Context' for FA Mode or
* 'application.Context' for Stage Mode.
* @permission N/A
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 10
*/
export default abstract class BaseContext {
/**
* Indicates the context is FA Mode or Stage Mode.
*
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
/**
* Indicates the context is FA Mode or Stage Mode.
*
* @since 10
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 8
*/

View File

@ -27,9 +27,16 @@ import contextConstant from '../@ohos.app.ability.contextConstant';
* @extends BaseContext
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* The base context of an ability or an application. It allows access to
* application-specific resources.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export default class Context extends BaseContext {
/**
* Indicates the capability of accessing application resources.
@ -37,9 +44,16 @@ export default class Context extends BaseContext {
* @type { resmgr.ResourceManager }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates the capability of accessing application resources.
* @type { resmgr.ResourceManager }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
resourceManager: resmgr.ResourceManager;
/**
@ -48,9 +62,16 @@ export default class Context extends BaseContext {
* @type { ApplicationInfo }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates configuration information about an application.
* @type { ApplicationInfo }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
applicationInfo: ApplicationInfo;
/**
@ -59,9 +80,16 @@ export default class Context extends BaseContext {
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates app cache dir.
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
cacheDir: string;
/**
@ -70,9 +98,16 @@ export default class Context extends BaseContext {
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates app temp dir.
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
tempDir: string;
/**
@ -81,9 +116,16 @@ export default class Context extends BaseContext {
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates app files dir.
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
filesDir: string;
/**
@ -92,9 +134,16 @@ export default class Context extends BaseContext {
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates app database dir.
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
databaseDir: string;
/**
@ -103,9 +152,16 @@ export default class Context extends BaseContext {
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates app preferences dir.
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
preferencesDir: string;
/**
@ -114,9 +170,16 @@ export default class Context extends BaseContext {
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates app bundle code dir.
* @type { string }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
bundleCodeDir: string;
/**
@ -173,9 +236,18 @@ export default class Context extends BaseContext {
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Create a module context
* @param { string } moduleName - Indicates the module name.
* @returns { Context } Returns the application context.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
createModuleContext(moduleName: string): Context;
/**
@ -199,8 +271,16 @@ export default class Context extends BaseContext {
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Get application context
* @returns { ApplicationContext } Returns the application context.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
getApplicationContext(): ApplicationContext;
}

View File

@ -17,16 +17,29 @@
* The class of an process information.
*
* @typedef ProcessInformation
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 9
* @crossplatform
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
/**
* The class of an process information.
*
* @since 10
* @crossplatform
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
export interface ProcessInformation {
/**
* @default process id
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 9
* @crossplatform
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
/**
* @default process id
* @since 10
* @crossplatform
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
pid: number;
@ -39,17 +52,29 @@ export interface ProcessInformation {
/**
* @default the name of the process
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 9
* @crossplatform
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
/**
* @default the name of the process
* @since 10
* @crossplatform
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
processName: string;
/**
* @default an array of the bundleNames running in the process
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @crossplatform
* @since 9
* @crossplatform
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
/**
* @default an array of the bundleNames running in the process
* @since 10
* @crossplatform
* @syscap SystemCapability.Ability.AbilityRuntime.Core
*/
bundleNames: Array<string>;
}

View File

@ -35,9 +35,15 @@ import dialogRequest from '../@ohos.app.ability.dialogRequest';
* @extends Context
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* The context of an ability. It allows access to ability-specific resources.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
export default class UIAbilityContext extends Context {
/**
* Indicates configuration information about an ability.
@ -45,9 +51,16 @@ export default class UIAbilityContext extends Context {
* @type { AbilityInfo }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates configuration information about an ability.
* @type { AbilityInfo }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
abilityInfo: AbilityInfo;
/**
@ -56,9 +69,16 @@ export default class UIAbilityContext extends Context {
* @type { HapModuleInfo }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Indicates configuration information about the module.
* @type { HapModuleInfo }
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 10
*/
currentHapModuleInfo: HapModuleInfo;
/**
@ -92,7 +112,6 @@ export default class UIAbilityContext extends Context {
* @throws { BusinessError } 16200001 - The caller has been released.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
@ -1155,13 +1174,15 @@ export default class UIAbilityContext extends Context {
* @throws { BusinessError } 16000050 - Internal error.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Destroys this Page ability.
* @param { AsyncCallback<void> } callback - The callback of terminateSelf.
* @throws { BusinessError } 401 - If the input parameter is not valid parameter.
* @throws { BusinessError } 16000001 - The specified ability does not exist.
* @throws { BusinessError } 16000004 - Can not start invisible component.
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
* @throws { BusinessError } 16000011 - The context does not exist.
* @throws { BusinessError } 16000050 - Internal error.
@ -1184,12 +1205,14 @@ export default class UIAbilityContext extends Context {
* @throws { BusinessError } 16000050 - Internal error.
* @syscap SystemCapability.Ability.AbilityRuntime.Core
* @StageModelOnly
* @crossplatform
* @since 9
*/
/**
* Destroys this Page ability.
* @returns { Promise<void> } The promise returned by the function.
* @throws { BusinessError } 16000001 - The specified ability does not exist.
* @throws { BusinessError } 16000004 - Can not start invisible component.
* @throws { BusinessError } 16000005 - The specified process does not have the permission.
* @throws { BusinessError } 16000009 - An ability cannot be started or stopped in Wukong mode.
* @throws { BusinessError } 16000011 - The context does not exist.
* @throws { BusinessError } 16000050 - Internal error.

View File

@ -22,18 +22,32 @@ import bundleManager from './../@ohos.bundle.bundleManager';
*
* @typedef AbilityInfo
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Obtains configuration information about an ability
*
* @typedef AbilityInfo
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
export interface AbilityInfo {
/**
* Indicates the name of the bundle containing the ability
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the name of the bundle containing the ability
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly bundleName: string;
/**
@ -41,9 +55,16 @@ export interface AbilityInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the name of the .hap package to which the capability belongs
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly moduleName: string;
/**
@ -51,9 +72,16 @@ export interface AbilityInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Ability simplified class name
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly name: string;
/**
@ -61,9 +89,16 @@ export interface AbilityInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the label of the ability
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly label: string;
/**
@ -71,9 +106,16 @@ export interface AbilityInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the label id of the ability
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly labelId: number;
/**
@ -81,9 +123,16 @@ export interface AbilityInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the ability
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly description: string;
/**
@ -91,9 +140,16 @@ export interface AbilityInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the description id of the ability
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly descriptionId: number;
/**
@ -101,9 +157,16 @@ export interface AbilityInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the icon of the ability
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly icon: string;
/**
@ -111,9 +174,16 @@ export interface AbilityInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the icon id of the ability
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly iconId: number;
/**
@ -158,9 +228,16 @@ export interface AbilityInfo {
*
* @type { bundleManager.LaunchType }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Enumerates ability launch type
*
* @type { bundleManager.LaunchType }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly launchType: bundleManager.LaunchType;
/**
@ -216,9 +293,16 @@ export interface AbilityInfo {
*
* @type { ApplicationInfo }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Obtains configuration information about an application
*
* @type { ApplicationInfo }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly applicationInfo: ApplicationInfo;
/**
@ -226,9 +310,16 @@ export interface AbilityInfo {
*
* @type { Array<Metadata> }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the metadata of ability
*
* @type { Array<Metadata> }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly metadata: Array<Metadata>;
/**

View File

@ -22,18 +22,32 @@ import bundleManager from './../@ohos.bundle.bundleManager';
*
* @typedef ApplicationInfo
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Obtains configuration information about an application
*
* @typedef ApplicationInfo
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
export interface ApplicationInfo {
/**
* Indicates the application name, which is the same as {@code bundleName}
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the application name, which is the same as {@code bundleName}
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly name: string;
/**
@ -41,9 +55,16 @@ export interface ApplicationInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Description of application
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly description: string;
/**
@ -51,9 +72,16 @@ export interface ApplicationInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the description id of the application
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly descriptionId: number;
/**
@ -70,9 +98,16 @@ export interface ApplicationInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the label of the application
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly label: string;
/**
@ -80,9 +115,16 @@ export interface ApplicationInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the label id of the application
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly labelId: number;
/**
@ -90,9 +132,16 @@ export interface ApplicationInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the icon of the application
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly icon: string;
/**
@ -100,9 +149,16 @@ export interface ApplicationInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the icon id of the application
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly iconId: number;
/**
@ -128,9 +184,16 @@ export interface ApplicationInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the application source code path
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly codePath: string;
/**

View File

@ -23,18 +23,32 @@ import bundleManager from './../@ohos.bundle.bundleManager';
*
* @typedef HapModuleInfo
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Obtains configuration information about a hap module.
*
* @typedef HapModuleInfo
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
export interface HapModuleInfo {
/**
* Indicates the name of this hap module
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the name of this hap module
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly name: string;
/**
@ -42,9 +56,16 @@ export interface HapModuleInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the icon of this hap module
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly icon: string;
/**
@ -52,9 +73,16 @@ export interface HapModuleInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the icon id of this hap module
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly iconId: number;
/**
@ -62,9 +90,16 @@ export interface HapModuleInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the label of this hap module
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly label: string;
/**
@ -72,9 +107,16 @@ export interface HapModuleInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the label id of this hap module
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly labelId: number;
/**
@ -82,9 +124,16 @@ export interface HapModuleInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Describes the hap module
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly description: string;
/**
@ -92,9 +141,16 @@ export interface HapModuleInfo {
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the description of this hap module
*
* @type { number }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly descriptionId: number;
/**
@ -102,9 +158,16 @@ export interface HapModuleInfo {
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates main elementName of the hap module
*
* @type { string }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly mainElementName: string;
/**
@ -112,9 +175,16 @@ export interface HapModuleInfo {
*
* @type { Array<AbilityInfo> }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Obtains configuration information about abilities
*
* @type { Array<AbilityInfo> }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly abilitiesInfo: Array<AbilityInfo>;
/**
@ -131,9 +201,16 @@ export interface HapModuleInfo {
*
* @type { Array<Metadata> }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 9
*/
/**
* Indicates the metadata of ability
*
* @type { Array<Metadata> }
* @syscap SystemCapability.BundleManager.BundleFramework.Core
* @crossplatform
* @since 10
*/
readonly metadata: Array<Metadata>;
/**

View File

@ -56,6 +56,8 @@
"SystemCapability.Multimedia.Media.VideoEncoder",
"SystemCapability.Multimedia.Media.Spliter",
"SystemCapability.Multimedia.Media.Muxer",
"SystemCapability.Multimedia.Media.AVPlayer",
"SystemCapability.Multimedia.Media.AVRecorder",
"SystemCapability.Multimedia.AVSession.Core",
"SystemCapability.Multimedia.AVSession.Manager",
"SystemCapability.Multimedia.Audio.Core",

View File

@ -66,6 +66,8 @@
"SystemCapability.Multimedia.Media.VideoEncoder",
"SystemCapability.Multimedia.Media.Spliter",
"SystemCapability.Multimedia.Media.Muxer",
"SystemCapability.Multimedia.Media.AVPlayer",
"SystemCapability.Multimedia.Media.AVRecorder",
"SystemCapability.Multimedia.AVSession.Core",
"SystemCapability.Multimedia.AVSession.Manager",
"SystemCapability.Multimedia.Audio.Core",

View File

@ -6,7 +6,6 @@
"SystemCapability.PowerManager.BatteryManager.Core",
"SystemCapability.FileManagement.File.FileIO",
"SystemCapability.Startup.SystemInfo",
"SystemCapability.Sensors.Sensor",
"SystemCapability.PowerManager.DisplayPowerManager",
"SystemCapability.Communication.NFC.CardEmulation"
]

View File

@ -62,6 +62,8 @@
"SystemCapability.Multimedia.Media.VideoEncoder",
"SystemCapability.Multimedia.Media.Spliter",
"SystemCapability.Multimedia.Media.Muxer",
"SystemCapability.Multimedia.Media.AVPlayer",
"SystemCapability.Multimedia.Media.AVRecorder",
"SystemCapability.Multimedia.AVSession.Core",
"SystemCapability.Multimedia.AVSession.Manager",
"SystemCapability.Multimedia.Audio.Core",

View File

@ -54,6 +54,8 @@
"SystemCapability.Multimedia.Media.VideoEncoder",
"SystemCapability.Multimedia.Media.Spliter",
"SystemCapability.Multimedia.Media.Muxer",
"SystemCapability.Multimedia.Media.AVPlayer",
"SystemCapability.Multimedia.Media.AVRecorder",
"SystemCapability.Multimedia.AVSession.Core",
"SystemCapability.Multimedia.AVSession.Manager",
"SystemCapability.Multimedia.Audio.Core",

View File

@ -53,6 +53,8 @@
"SystemCapability.Multimedia.Media.VideoEncoder",
"SystemCapability.Multimedia.Media.Spliter",
"SystemCapability.Multimedia.Media.Muxer",
"SystemCapability.Multimedia.Media.AVPlayer",
"SystemCapability.Multimedia.Media.AVRecorder",
"SystemCapability.Multimedia.AVSession.Core",
"SystemCapability.Multimedia.AVSession.Manager",
"SystemCapability.Multimedia.Audio.Core",

View File

@ -0,0 +1,3 @@
[
"api_check: false"
]

View File

@ -17,55 +17,61 @@ const path = require('path');
const fs = require('fs');
function checkEntry(prId) {
let result = '';
let result = ['api_check: false'];
const sourceDirname = __dirname;
__dirname = 'interface/sdk-js/build-tools/api_check_plugin';
const mdFilesPath = path.resolve(sourceDirname, '../../../../', 'all_files.txt');
const execSync = require('child_process').execSync;
execSync('cd interface/sdk-js/build-tools/api_check_plugin && npm install');
let buffer = new Buffer.from("");
let i = 0, execute = false;
try {
const rules = require(path.resolve(__dirname, './code_style_rule.json'));
const administrators = new Set();
rules.administrators.forEach((administrator) => {
administrators.add(administrator.user);
})
const request = require(path.resolve(__dirname, './node_modules/sync-request'));
const { scanEntry } = require(path.resolve(__dirname, './src/api_check_plugin'));
result = scanEntry(mdFilesPath);
const { ApiCheckResult } = require(path.resolve(__dirname, './src/utils.js'));
if (!ApiCheckResult.format_check_result && prId && prId !== 'NA') {
// 默认搜寻100条评论
const commentRequestPath = `https://gitee.com/api/v5/repos/openharmony/interface_sdk-js/pulls/${prId}/comments?page=1&per_page=100&direction=desc`;
let res = request('GET', commentRequestPath, {
headers: {
'Content-Type': 'application/json;charset=UFT-8'
}
});
if (res.statusCode == 200) {
let resBody = new TextDecoder('utf-8').decode(res.body);
let comments = JSON.parse(`{"resultBody": ${resBody}}`);
let resultBody = comments.resultBody;
if (resultBody && resultBody.length && resultBody instanceof Array) {
for (let i = 0; i < resultBody.length; i++) {
const comment = resultBody[i];
if (comment && comment['user'] && comment['user']['id'] && administrators.has(String(comment['user']['id'])) &&
comment.body && /^approve api check$/.test(comment.body)) {
ApiCheckResult.format_check_result = true;
result = "['api_check: true']";
break;
}
}
}
const execSync = require('child_process').execSync;
do {
try {
buffer = execSync('cd interface/sdk-js/build-tools/api_check_plugin && npm install', {
timeout: 120000
});
execute = true;
} catch (error) {
}
} while (++i < 3 && !execute);
if (!execute) {
throw "npm install timeout";
}
const { removeDir } = require(path.resolve(__dirname, './src/utils'));
const { scanEntry, reqGitApi } = require(path.resolve(__dirname, './src/api_check_plugin'));
result = scanEntry(mdFilesPath);
result = reqGitApi(result, prId);
removeDir(path.resolve(__dirname, 'node_modules'));
} catch (error) {
// catch error
result = `API_CHECK_ERROR : ${error}`;
result.push(`API_CHECK_ERROR : ${error}`);
result.push(`buffer : ${buffer.toString()}`);
} finally {
const { writeResultFile } = require('./src/utils');
writeResultFile(result, path.resolve(__dirname, './Result.txt'), {});
}
}
function removeDir(url) {
let statObj = fs.statSync(url);
if (statObj.isDirectory()) {
let dirs = fs.readdirSync(url);
dirs = dirs.map(dir => path.join(url, dir));
for (let i = 0; i < dirs.length; i++) {
removeDir(dirs[i]);
}
fs.rmdirSync(url);
} else {
fs.unlinkSync(url);
}
}
function writeResultFile(resultData, outputPath, option) {
fs.writeFile(path.resolve(__dirname, outputPath), JSON.stringify(resultData, null, 2), option, err => {
if (err) {
console.error(`ERROR FOR CREATE FILE:${err}`);
} else {
console.log('API CHECK FINISH!');
}
});
}
checkEntry(process.argv[2]);

View File

@ -23,6 +23,7 @@ alterase
alternating
altitudes
amr
animatable
annually
antialias
apdu
@ -404,6 +405,7 @@ missions
mkdtemp
mmax
mmi
mmicode
mnc
moderately
moitor
@ -460,6 +462,8 @@ operatorconfigs
opkey
opl
opname
option
originating
osd
ott
ounted
@ -585,6 +589,7 @@ sak
satellites
scdma
sco
scrambling
screenlock
screensaver
scrolldown

View File

@ -15,6 +15,7 @@
const path = require('path');
const fs = require('fs');
const request = require("sync-request")
const { checkSpelling } = require('./check_spelling');
const { checkAPIDecorators } = require('./check_decorator');
const { checkPermission } = require('./check_permission');
@ -27,6 +28,7 @@ const { checkEventSubscription } = require('./check_eventSubscription');
const { hasAPINote, ApiCheckResult, requireTypescriptModule, commentNodeWhiteList } = require('./utils');
const ts = requireTypescriptModule();
let result = require('../check_result.json');
const rules = require('../code_style_rule.json')
function checkAPICodeStyle(url) {
if (fs.existsSync(url)) {
@ -110,3 +112,40 @@ function scanEntry(url) {
return result.scanResult;
}
exports.scanEntry = scanEntry;
function reqGitApi(scanResult, prId) {
const administrators = new Set();
rules.administrators.forEach((administrator) => {
administrators.add(administrator.user);
})
if (ApiCheckResult.format_check_result || !prId || prId === 'NA') {
return scanResult;
}
const commentRequestPath = `https://gitee.com/api/v5/repos/openharmony/interface_sdk-js/pulls/${prId}/comments?page=1&per_page=100&direction=desc`;
let res = request('GET', commentRequestPath, {
headers: {
'Content-Type': 'application/json;charset=UFT-8'
}
});
if (res.statusCode !== 200) {
throw `The giteeAPI access failed, StatusCode:${res.statusCode}`;
}
let resBody = new TextDecoder('utf-8').decode(res.body);
let comments = JSON.parse(`{"resultBody": ${resBody}}`);
let resultBody = comments.resultBody;
if (!resultBody || resultBody.length === 0 || !(resultBody instanceof Array)) {
throw "The format of data returned by giteeAPI is incorrect";
}
for (let i = 0; i < resultBody.length; i++) {
const comment = resultBody[i];
if (comment && comment['user'] && comment['user']['id'] && administrators.has(String(comment['user']['id'])) &&
comment.body && /^approve api check$/.test(comment.body)) {
ApiCheckResult.format_check_result = true;
scanResult = ['api_check: true'];
break;
}
}
return scanResult;
}
exports.reqGitApi = reqGitApi;

View File

@ -0,0 +1,29 @@
# 基础API解析工具
## 简介
该工具可用于解析d.ts文件中的API并汇总成表格提供给应用开发者
## 目录
```
└─API #存放需要扫描的d.ts文件的目录
```
## 使用方法
### 目录配置
新建API文件夹放置d.ts文件。
### 安装
需要安装npm依赖环境在package.json同级目录下执行npm install。
### 使用工具
在package.json同级目录下执行npm run collect。
## 相关文件夹
[collect_api](https://gitee.com/openharmony/interface_sdk-js/tree/master/build-tools/collect_api)

View File

@ -0,0 +1,758 @@
/*
* Copyright (c) 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
*
* 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.
*/
const fs = require('fs');
const ts = require('typescript');
const ExcelJS = require('exceljs')
const path = require('path');
const { sys } = require('typescript');
// 是否统计type类型API的开关true表示统计
const typeCollection = true;
// 是否不合并同名函数的开关true不合并
const isNotMerge = true;
// 解析文件 文本内容并将结果push到列表中并去重
function parse(files) {
const api = [];
const exportApi = [];
const returnDeclarationArr = new Set([]);
const hash = new Set([]);
const fileContentList = [];
files.forEach(file => {
let fileContent = fs.readFileSync(file, 'utf-8');
fileContentList.push({
fileName: path.basename(file).replace(/.d.ts$/g, '.ts'),
fileContent: fileContent,
fileRoot: file
})
});
fileContentList.forEach(item => {
const fileName = item.fileName.replace(/\.d.ts$/g, '.ts');
let packageName = item.fileRoot.indexOf("component\\ets\\") >= 0 ||
item.fileRoot.indexOf("component/ets/") >= 0 ? "ArkUI" : fileName.replace((/\@|.ts$/g), "").replace(/D:\\/g, "")
ts.transpileModule(item.fileContent, {
compilerOptions: {
"target": ts.ScriptTarget.ES2017
},
fileName: fileName,
transformers: { before: [getReturnDeclarationArr(packageName, exportApi, returnDeclarationArr)] }
})
});
fileContentList.forEach(item => {
const fileName = item.fileName.replace(/\.d.ts$/g, '.ts');
let packageName = item.fileRoot.indexOf("component\\ets\\") >= 0 ||
item.fileRoot.indexOf("component/ets/") >= 0 ? "ArkUI" : fileName.replace(/\@|.ts$/g, "").replace(/D:\\/g, "");
ts.transpileModule(item.fileContent, {
compilerOptions: {
"target": ts.ScriptTarget.ES2017
},
fileName: fileName,
transformers: { before: [processDeclarationSourceFile(packageName, api, exportApi, returnDeclarationArr, hash, item.fileRoot)] }
})
});
return api;
}
// 获取返回值类型
function visitAllNode(node, returnDeclarationArr) {
if ((ts.isMethodDeclaration(node) || ts.isFunctionDeclaration(node)) && node && node.type &&
ts.isTypeReferenceNode(node.type)) {
returnDeclarationArr.add(node.type.typeName.getText());
}
node.getChildren().forEach(item => {
visitAllNode(item, returnDeclarationArr)
});
}
// 获取导入Api的数组
function getExportApi(node, packageName, exportApi) {
node.statements.forEach(stat => {
if (ts.isModuleDeclaration(stat)) {
if (stat.getText().indexOf('namespace') > 0) {
let apiInfo = {
isSystemApi: '公开API',
version: '',
deprecated: '',
permission: 'N/A',
sysCap: 'N/A',
model: ''
}
exportApi.push({
packageName: packageName,
className: stat.name.escapedText.toString(),
methodName: '',
apiInfo: getApiInfo(stat, apiInfo)
})
}
}
});
}
// 获取返回值类型和命名空间
const getReturnDeclarationArr = (packageName, exportApi, returnDeclarationArr) => {
return (context) => {
return (node) => {
visitAllNode(node, returnDeclarationArr);
getExportApi(node, packageName, exportApi);
return node;
}
}
}
// 搜集API接口并去重
function processDeclarationSourceFile(packageName, api, exportApi, returnDeclarationArr, hash, dtsPath) {
return (context) => {
return (node) => {
const statements = node.statements;
const currentClassFuncSet = new Set([]);
const currentTypeList = new Array();
getCurrentTypeList(statements, currentTypeList);
statements.forEach(stat => {
let apiInfo = {
isSystemApi: '公开API',
version: '',
deprecated: '',
permission: 'N/A',
sysCap: 'N/A',
model: '',
headimport: 'N/A',
endexport: 'N/A',
}
collectApi(packageName, api, stat, apiInfo, exportApi, returnDeclarationArr, hash, dtsPath,
currentTypeList, currentClassFuncSet);
});
return node;
}
}
}
function getCurrentTypeList(statements, currentTypeList) {
statements.forEach(stat => {
if (ts.isTypeAliasDeclaration(stat)) {
if (stat.type.types) {
let typeObj = {
name: stat.name.escapedText,
value: []
}
stat.type.types.forEach(type => {
if (type.literal && type.literal.text) {
typeObj.value.push(type.literal.text);
}
});
if (typeObj.value.length > 0) {
currentTypeList.push(typeObj);
}
}
}
});
}
function collectApi(packageName, api, stat, apiInfo, exportApi, returnDeclarationArr, hash, dtsPath, currentTypeList,
currentClassFuncSet) {
if (ts.isInterfaceDeclaration(stat)) {
collectInterfaceDeclaration(stat, packageName, api, exportApi, returnDeclarationArr, hash, apiInfo,
currentTypeList, dtsPath);
} else if (ts.isModuleDeclaration(stat)) {
collectModuleDeclaration(stat, packageName, api, exportApi, returnDeclarationArr, hash, apiInfo,
currentTypeList, dtsPath);
} else if (ts.isClassDeclaration(stat)) {
collectClassDeclaration(stat, packageName, api, exportApi, returnDeclarationArr, hash, apiInfo,
currentTypeList, dtsPath);
} else if (ts.isEnumDeclaration(stat)) {
collectEnumDeclaration(stat, packageName, api, exportApi, returnDeclarationArr, hash, apiInfo,
currentTypeList, dtsPath);
} else if (ts.isVariableStatement(stat)) {
const apiName = stat.declarationList.declarations[0].name.escapedText;
addApi(packageName, 'global', apiName, stat.getText().trim(), getApiInfo(stat, apiInfo),
'Decorator', api, hash, dtsPath, 8);
} else {
collectSpecialApi(stat, packageName, api, hash, currentClassFuncSet, dtsPath, exportApi, apiInfo);
}
}
function collectSpecialApi(stat, packageName, api, hash, currentClassFuncSet, dtsPath, exportApi, apiInfo) {
if (ts.isMethodDeclaration(stat) || ts.isMethodSignature(stat) || ts.isFunctionDeclaration(stat)) {
const methodName = stat.name.escapedText ? stat.name.escapedText.toString() : stat.name.text.toString();
let className = '';
exportApi.forEach(item => {
if (item.methodName === methodName && item.packageName === packageName) {
className = item.className
if (item.apiInfo) {
apiInfo = item.apiInfo;
}
}
});
addFunctionOnOffApi(packageName, className, methodName, getApiInfo(stat, apiInfo), 'Method', api,
hash, currentClassFuncSet, stat, dtsPath);
}
}
function collectInterfaceDeclaration(stat, packageName, api, exportApi, returnDeclarationArr, hash, apiInfo, currentTypeList, dtsPath) {
const className = stat.name.escapedText.toString();
const interfaceChildren = stat.members;
let tmpApiInfo = getApiInfo(stat, apiInfo);
collectEachChildNode(interfaceChildren, packageName, className, 'Field', api, exportApi, returnDeclarationArr, hash,
tmpApiInfo, currentTypeList, dtsPath);
}
function collectClassDeclaration(stat, packageName, api, exportApi, returnDeclarationArr, hash, apiInfo, currentTypeList, dtsPath) {
const className = stat.name.escapedText.toString();
const classChildren = stat.members;
let tmpApiInfo = getApiInfo(stat, apiInfo);
collectEachChildNode(classChildren, packageName, className, 'Field', api, exportApi, returnDeclarationArr, hash,
tmpApiInfo, currentTypeList, dtsPath);
}
function collectEnumDeclaration(stat, packageName, api, exportApi, returnDeclarationArr, hash, apiInfo, currentTypeList, dtsPath) {
const className = stat.name.escapedText.toString();
const enumChildren = stat.members;
let tmpApiInfo = getApiInfo(stat, apiInfo);
collectEachChildNode(enumChildren, packageName, className, 'Enum', api, exportApi, returnDeclarationArr, hash,
tmpApiInfo, currentTypeList, dtsPath)
}
function collectModuleDeclaration(stat, packageName, api, exportApi, returnDeclarationArr, hash, apiInfo, currentTypeList, dtsPath) {
const className = stat.name.escapedText ? stat.name.escapedText.toString() : stat.name.text.toString();
const moduleChildren = stat.body.statements;
let tmpApiInfo = getApiInfo(stat, apiInfo);
collectEachChildNode(moduleChildren, packageName, className, 'Field', api, exportApi, returnDeclarationArr, hash,
tmpApiInfo, currentTypeList, dtsPath)
}
function collectTypeApi(child, packageName, className, api, hash, apiInfo, dtsPath) {
let typeObj = {
name: child.name.escapedText,
value: []
}
if (child.type.types) {
child.type.types?.forEach(type => {
collectTypeApiInTypes(type, apiInfo, child, api, hash, dtsPath, typeObj, packageName);
});
} else if (child.type.members) {
child.type.members?.forEach(member => {
collectTypeApiInMembers(member, apiInfo, child, api, hash, dtsPath, typeObj, packageName, className);
})
}
return typeObj;
}
function collectTypeApiInTypes(type, apiInfo, child, api, hash, dtsPath, typeObj, packageName) {
if (type.literal && type.literal.text) {
typeObj.value.push(type.literal.text);
if (typeCollection && type.literal) {
let faterApiInfo = JSON.parse(JSON.stringify(apiInfo));
addApi(packageName, child.name.escapedText, type.literal.text, child.getText(),
getApiInfo(child, faterApiInfo), 'Type', api, hash, dtsPath, 1);
}
} else {
if (type.getText() != '') {
typeObj.value.push(type.getText());
if (typeCollection && type.literal) {
let faterApiInfo = JSON.parse(JSON.stringify(apiInfo));
addApi(packageName, child.name.escapedText, type.getText(), child.getText(),
getApiInfo(child, faterApiInfo), 'Type', api, hash, dtsPath, 2);
}
}
}
}
function collectTypeApiInMembers(member, apiInfo, child, api, hash, dtsPath, typeObj, packageName, className) {
member.type.types?.forEach(type => {
if (type.literal && type.literal.text) {
typeObj.value.push(type.literal.text);
if (typeCollection) {
let faterApiInfo = JSON.parse(JSON.stringify(apiInfo));
addApi(packageName, child.name.escapedText, type.literal.text, child.getText(),
getApiInfo(child, faterApiInfo), 'Type', api, hash, dtsPath, 3);
}
} else {
if (type.getText() != '') {
typeObj.value.push(type.getText());
if (typeCollection) {
let faterApiInfo = JSON.parse(JSON.stringify(apiInfo));
addApi(packageName, className, child.name.escapedText, child.getText(),
getApiInfo(child, faterApiInfo), 'Type', api, hash, dtsPath, 4);
}
}
}
});
}
function collectEachChildNode(children, packageName, className, faterApiType, api, exportApi, returnDeclarationArr,
hash, apiInfo, currentTypeList, dtsPath) {
const currentClassFunSet = new Set([]);
children.forEach(child => {
if (ts.isTypeAliasDeclaration(child)) {
if (child.type) {
let typeObj = collectTypeApi(child, packageName, className, api, hash, apiInfo, dtsPath);
if (typeObj.value.length > 0) {
currentTypeList.push(typeObj)
}
}
}
});
children.forEach(child => {
let faterApiInfo = JSON.parse(JSON.stringify(apiInfo));
let apiType = new String(faterApiType);
if (/export.*\{.*\}/g.test(child.getText())) {
exportApi.push({
packageName: packageName,
className: className,
methodName: child.getText().replace("export", '').replace('{', '').replace('}', '').replace(';', '').trim(),
apiInfo: faterApiInfo
})
return
}
if (ts.isInterfaceDeclaration(child)) {
collectInterfaceDeclaration(child, packageName, api, exportApi, returnDeclarationArr, hash, faterApiInfo, currentTypeList, dtsPath);
} else if (ts.isModuleDeclaration(child)) {
collectModuleDeclaration(child, packageName, api, exportApi, returnDeclarationArr, hash, faterApiInfo, currentTypeList, dtsPath);
} else if (ts.isClassDeclaration(child)) {
collectClassDeclaration(child, packageName, api, exportApi, returnDeclarationArr, hash, faterApiInfo, currentTypeList, dtsPath);
} else if (ts.isEnumDeclaration(child)) {
collectEnumDeclaration(child, packageName, api, exportApi, returnDeclarationArr, hash, faterApiInfo, currentTypeList, dtsPath);
} else {
if ((ts.isMethodDeclaration(child) || ts.isMethodSignature(child) || ts.isFunctionDeclaration(child)) &&
(child.name.escapedText === 'on' || child.name.escapedText === 'off') && child.parameters && child.parameters.length > 0) {
apiType = 'Method';
collectSubscriptionTypeApi(child, apiType, packageName, className, faterApiType, api, currentTypeList,
hash, currentClassFunSet, dtsPath);
} else {
collectOtherApi(child, packageName, className, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath, returnDeclarationArr)
}
}
});
}
function collectOtherApi(child, packageName, className, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath, returnDeclarationArr) {
let methodName = "";
if (isSpecialMethod(child)) {
if (child.name) {
methodName = child.name.getText();
} else {
methodName = className;
}
apiType = 'Method'
} else if (ts.isPropertyDeclaration(child) || ts.isPropertySignature(child)) {
if (child.type && child.type.parameters) {
methodName = child.name.escapedText;
apiType = 'Method'
} else {
methodName = child.name.escapedText;
apiType = 'Field';
}
} else {
if (child.name) {
methodName = child.name.getText();
}
}
if (methodName !== "") {
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
} else {
if (child.getText().indexOf("constructor") === 0) {
methodName = 'constructor';
apiType = 'Method';
} else if (child.getText().indexOf("const") === 0) {
const infoObj = collectFieleOrConstant(apiType, methodName, child, returnDeclarationArr);
methodName = infoObj.methodName;
apiType = infoObj.apiType;
} else if (/\w+:\s*\w+/g.test(child.getText())) {
apiType = 'Field';
methodName = child.getText().split(":")[0].trim();
}
if (methodName != '') {
addApi(packageName, className, methodName, child.getText(),
getApiInfo(child, faterApiInfo), apiType, api, hash, dtsPath, 5);
}
}
}
function isSpecialMethod(child){
return ts.isMethodDeclaration(child) || ts.isMethodSignature(child) || ts.isFunctionDeclaration(child) ||
ts.isCallSignatureDeclaration(child) || ts.isConstructSignatureDeclaration(child) ||
ts.isIndexSignatureDeclaration(child);
}
function collectFieleOrConstant(apiType, methodName, child, returnDeclarationArr) {
if (child.getText().replace("const", "").indexOf(":") > 0) {
if (returnDeclarationArr.has(child.getText().replace("const", "").split(":")[1].trim())) {
apiType = 'Field';
} else {
apiType = 'Constant';
}
methodName = child.getText().replace('const', "").split(":")[0].trim();
} else if (child.getText().replace("const", "").indexOf("=") > 0) {
if (returnDeclarationArr.has(child.getText().replace("const", "").split("=")[1].trim())) {
apiType = 'Field';
} else {
apiType = 'Constant';
}
methodName = child.getText().replace('const', "").split("=")[0].trim();
}
return { apiType, methodName };
}
function collectSubscriptionTypeApi(child, apiType, packageName, className, faterApiInfo, api, currentTypeList,
hash, currentClassFunSet, dtsPath) {
for (let i = 0; i < child.parameters.length; i++) {
const param = child.parameters[i];
if (isCommonSubscriptionType(param)) {
if (param.type && param.type.literal && param.type.literal.text) {
collectTypeOrEventApi(packageName, className, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath, param);
} else if (param.type && param.type.types && param.type.types.length > 0) {
collectSpecialSubscriptionTypeApi(param, packageName, className, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
} else if (param.type && param.type.typeName && param.type.typeName.escapedText) {
inCurrentTypeListApi(packageName, className, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath, currentTypeList, param);
} else if (param.type && param.type.typeName && param.type.typeName.left &&
param.type.typeName.right) {
let methodName = child.name.escapedText + '_' + param.type.typeName.left.escapedText + '_' +
param.type.typeName.right.escapedText;
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
} else {
let methodName = child.name.escapedText;
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
}
break;
} else {
let methodName = child.name.escapedText;
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
}
}
}
function isCommonSubscriptionType(param) {
return param.name.escapedText === 'type' || param.name.escapedText === 'event' ||
param.name.escapedText === 'eventType';
}
function collectSpecialSubscriptionTypeApi(param, packageName, className, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath) {
param.type.types.forEach(type => {
if (type.literal && type.literal.text) {
const methodName = child.name.escapedText + "_" + type.literal.text;
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
}
});
}
function inCurrentTypeListApi(packageName, className, faterApiInfo, apiType, api, hash, currentClassFunSet, child,
dtsPath, currentTypeList, param) {
if (currentTypeList && currentTypeList.length > 0) {
currentTypeList.forEach(type => {
if (type.name === param.type.typeName.escapedText) {
type.value.forEach(typeString => {
let methodName = child.name.escapedText + "_" + typeString;
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
});
}
});
} else {
let methodName = child.name.escapedText;
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
}
}
function collectTypeOrEventApi(packageName, className, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath, param) {
const typeTextArr = param.getText().replace(/\s*/g, "").split(':');
if (typeTextArr[0] === "type" || typeTextArr[0] === "event") {
let methodName = child.name.escapedText + '_' + param.type.literal.text;
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
} else {
let methodName = child.name.escapedText + '_' + param.type.literal.text;
addFunctionOnOffApi(packageName, className, methodName, faterApiInfo, apiType, api,
hash, currentClassFunSet, child, dtsPath);
}
}
function addFunctionOnOffApi(packageName, className, methodName, apiInfo, apiType, api,
hash, currentClassFunSet, childNode, dtsPath) {
// 合并同名函数
if (currentClassFunSet.has(methodName) && !isNotMerge) {
collectSameNameApiText(api, packageName, className, methodName, childNode);
} else {
notMergeSameNameFun(packageName, className, methodName, apiInfo, apiType, api,
hash, currentClassFunSet, childNode, dtsPath);
}
}
function collectSameNameApiText(api, packageName, className, methodName, childNode) {
for (let i = 0; i < api.length; i++) {
const curApi = api[i];
if (curApi.packageName === packageName && curApi.className === className &&
curApi.methodName === methodName) {
if (curApi.methodText.indexOf(`${childNode.getText().replace('declare', '').trim()}`) < 0) {
curApi.methodText += `\n${childNode.getText().replace('declare', '').replace(/\r|\n/ig, '').trim()}`;
break;
}
}
}
}
function notMergeSameNameFun(packageName, className, methodName, apiInfo, apiType, api,
hash, currentClassFunSet, childNode, dtsPath) {
if (!currentClassFunSet.has(methodName)) {
currentClassFunSet.add(methodName);
addApi(packageName, className, methodName, childNode.getText().replace('declare', '').trim(),
getApiInfo(childNode, apiInfo), apiType, api, hash, dtsPath, 6);
} else {
if (childNode.getFullText().indexOf('\/**') >= 0) {
addApi(packageName, className, methodName, childNode.getText().replace('declare', '').trim(),
getApiInfo(childNode, apiInfo), apiType, api, hash, dtsPath, 7);
} else {
let firstApiInfo = {};
handleSameNameApiJsDoc(api, firstApiInfo, packageName, className, methodName);
addApi(packageName, className, methodName, childNode.getText().replace('declare', '').trim(),
firstApiInfo, apiType, api, hash, dtsPath, 8);
}
}
}
function handleSameNameApiJsDoc(api, firstApiInfo, packageName, className, methodName) {
for (let i = 0; i < api.length; i++) {
const curApi = api[i];
if (curApi.packageName === packageName && curApi.className === className &&
curApi.methodName === methodName) {
firstApiInfo.isSystemApi = curApi.isSystemApi;
firstApiInfo.version = curApi.version;
firstApiInfo.sysCap = curApi.sysCap;
firstApiInfo.permission = curApi.permission;
firstApiInfo.model = curApi.model;
firstApiInfo.deprecated = curApi.deprecated;
}
}
}
function getApiInfo(node, apiInfo) {
const notesStr = node.getFullText().replace(node.getText(), "");
apiInfo.model = getModelInfo(notesStr);
apiInfo.errorCode = getErrorCode(notesStr);
apiInfo.deprecated = getDeprecatedInfo(notesStr);
apiInfo.permission = getPermissionInfo(notesStr);
apiInfo.isSystemApi = getSystemApi(notesStr);
apiInfo.version = getSinceVersion(notesStr);
apiInfo.sysCap = getSyscap(notesStr);
apiInfo.formInfo = isForm(notesStr);
apiInfo.isCrossPlatform = isCrossPlatform(notesStr);
return apiInfo;
}
function getSystemApi(notesStr) {
let isSystemApi = '';
if (/\@[S|s][Y|y][S|s][T|t][E|e][M|m][A|a][P|p][I|i]/g.test(notesStr)) {
isSystemApi = '系统API';
} else {
isSystemApi = '公开API';
}
}
function getSinceVersion(notesStr) {
let version;
if (/\@[S|s][I|i][N|n][C|c][E|e]\s*(\d+)/g.test(notesStr)) {
notesStr.replace(/\@[S|s][I|i][N|n][C|c][E|e]\s*(\d+)/g, (versionInfo) => {
version = versionInfo.replace(/\@[S|s][I|i][N|n][C|c][E|e]/g, '').trim();
})
} else {
version = 'N/A';
}
return version;
}
function getSyscap(notesStr) {
let syscap = '';
if (/\@[S|s][Y|y][S|s][C|c][A|a][P|p]\s*((\w|\.|\/|\{|\@|\}|\s)+)/g.test(notesStr)) {
notesStr.replace(/\@[S|s][Y|y][S|s][C|c][A|a][P|p]\s*((\w|\.|\/|\{|\@|\}|\s)+)/g, sysCapInfo => {
syscap = sysCapInfo.replace(/\@[S|s][Y|y][S|s][C|c][A|a][P|p]/g, '').trim();
})
}
return syscap;
}
function isForm(notesStr) {
let formInfo = '';
if (/\@form/g.test(notesStr)) {
formInfo = '是';
} else {
formInfo = '否';
}
return formInfo;
}
function getPermissionInfo(notesStr) {
let permission = ''
if (/\@[P|p][E|e][R|r][M|m][I|i][S|s][S|s][I|i][O|o][N|n]\s*((\w|\.|\/|\{|\@|\}|\s)+)/g.test(notesStr)) {
notesStr.replace(/\@[P|p][E|e][R|r][M|m][I|i][S|s][S|s][I|i][O|o][N|n]\s*((\w|\.|\/|\{|\@|\}|\s)+)/g,
permissionInfo => {
permission = permissionInfo.replace(
/\@[P|p][E|e][R|r][M|m][I|i][S|s][S|s][I|i][O|o][N|n]/g, '').trim();
return permission;
})
} else {
permission = 'N/A';
}
return permission;
}
function getDeprecatedInfo(notesStr) {
let deprecated = '';
if (/\@[D|d][E|e][P|p][R|r][E|e][C|c][A|a][T|t][E|e][D|d].*[S|s][I|i][N|n][C|c][E|e]\s*(\d+)/g.test(notesStr)) {
notesStr.replace(/\@[D|d][E|e][P|p][R|r][E|e][C|c][A|a][T|t][E|e][D|d].*[S|s][I|i][N|n][C|c][E|e]\s*(\d+)/g,
deprecatedInfo => {
deprecated = deprecatedInfo.replace(
/\@[D|d][E|e][P|p][R|r][E|e][C|c][A|a][T|t][E|e][D|d].*[S|s][I|i][N|n][C|c][E|e]\s*/g, '').trim();
})
} else {
deprecated = 'N/A';
}
return deprecated;
}
function getErrorCode(notesStr) {
let errorCode = '';
if (/\@throws { BusinessError } \d{2,18}/g.test(notesStr)) {
notesStr.replace(/\@throws { BusinessError } \d{2,18}/g, (code) => {
if (errorCode === '') {
errorCode += `${code.replace(/\@throws { BusinessError } /, '')}`;
} else {
errorCode += `,${code.replace(/\@throws { BusinessError } /, '')}`;
}
})
} else {
errorCode = 'N/A';
}
return errorCode;
}
function getModelInfo(notesStr) {
let model = '';
if (/\@[F|f][A|a][M|m][O|o][D|d][E|e][L|l][O|o][N|n][L|l][Y|y]/g.test(notesStr)) {
notesStr.replace(/\@[F|f][A|a][M|m][O|o][D|d][E|e][L|l][O|o][N|n][L|l][Y|y]/g, modelInfo => {
model = modelInfo;
})
} else if (/\@[S|s][T|t][A|a][G|g][E|e][M|m][O|o][D|d][E|e][L|l][O|o][N|n][L|l][Y|y]/g.test(notesStr)) {
notesStr.replace(/\@[S|s][T|t][A|a][G|g][E|e][M|m][O|o][D|d][E|e][L|l][O|o][N|n][L|l][Y|y]/g, modelInfo => {
model = modelInfo;
})
} else {
model = 'N/A';
}
return model;
}
function isCrossPlatform(notesStr) {
let isCrossPlatform = '';
if (/\@crossplatform/g.test(notesStr)) {
isCrossPlatform = '是';
} else {
isCrossPlatform = '否';
}
return isCrossPlatform;
}
function addApi(packageName, className, methodName, methodText, apiInfo, apiType, api, hash, dtsPath, type) {
let recard = isNotMerge ? `${packageName}.${className}/${methodName}/${methodText}` :
`${packageName}.${className}/${methodName}`
if (!hash.has(recard)) {
hash.add(recard);
api.push({
packageName: packageName,
className: className,
methodName: methodName,
methodText: methodText.replace(/export\s/g, ""),
isSystemApi: apiInfo.isSystemApi,
version: apiInfo.version,
deprecated: apiInfo.deprecated,
apiType: apiType,
sysCap: apiInfo.sysCap,
permission: apiInfo.permission,
model: apiInfo.model,
dtsPath: dtsPath,
errorCode: apiInfo.errorCode,
formInfo: apiInfo.formInfo,
isCrossPlatform: apiInfo.isCrossPlatform
})
}
}
function readFile(dir, utFiles) {
try {
const files = fs.readdirSync(dir);
files.forEach((element) => {
const filePath = path.join(dir, element);
const status = fs.statSync(filePath);
if (status.isDirectory()) {
readFile(filePath, utFiles);
} else {
if (/\.d\.ts/.test(filePath)) {
utFiles.push(filePath)
}
}
})
} catch (e) {
console.error('ETS ERROR: ' + e);
}
}
function exportData() {
const dir = path.resolve(__dirname, './API');
let fileList = [];
readFile(dir, fileList);
let api = parse(fileList);
excel(api);
}
async function excel(api) {
let buffer = await getExcelBuffer(api)
fs.writeFile('Js_Api.xlsx', buffer, function (err) {
if (err) {
console.error(err);
return;
}
});
}
async function getExcelBuffer(api) {
const workbook = new ExcelJS.Workbook();
const sheet = workbook.addWorksheet('Js Api', { views: [{ xSplit: 1 }] });
sheet.getRow(1).values = ['模块名', '类名', '方法名', '函数', '类型', 'SysCap',
'权限', '支持起始版本', '访问级别', '是否为卡片', '是否支持跨平台']
for (let i = 1; i <= api.length; i++) {
const apiData = api[i - 1];
sheet.getRow(i + 1).values = [apiData.packageName, apiData.className, apiData.methodName,
apiData.methodText, apiData.apiType, apiData.sysCap, apiData.permission,
apiData.version, apiData.isSystemApi, apiData.formInfo, apiData.isCrossPlatform]
}
const buffer = await workbook.xlsx.writeBuffer();
return buffer;
}
exportData();

View File

@ -0,0 +1,20 @@
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"collect": "node collect_base_api.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"exceljs": "^4.3.0",
"fs": "0.0.1-security",
"path": "^0.12.7",
"typescript": "^4.8.2"
},
"devDependencies": {
"@types/node": "^18.11.9"
}
}