1# 元能力子系统JS API变更 2 3OpenHarmony 3.2 Beta1版本相较于OpenHarmony 3.1 Release版本,元能力子系统的API变更如下: 4 5## 接口变更 6 7| 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | 8|---|---|---|---| 9| AbilityContext | AbilityContext | restoreWindowStage(localStorage: LocalStorage) : void; | 新增 | 10| AbilityContext | AbilityContext | requestPermissionsFromUser(permissions: Array\<string>, requestCallback: AsyncCallback\<PermissionRequestResult>) : void;<br>requestPermissionsFromUser(permissions: Array\<string>) : Promise\<PermissionRequestResult>; | 新增 | 11| AbilityContext | AbilityContext | setMissionIcon(icon: image.PixelMap, callback:AsyncCallback\<void>): void;<br>setMissionIcon(icon: image.PixelMap): Promise\<void>; | 新增 | 12| AbilityContext | AbilityContext | setMissionLabel(label: string, callback:AsyncCallback\<void>): void;<br>setMissionLabel(label: string): Promise\<void>; | 新增 | 13| AbilityContext | AbilityContext | disconnectAbility(connection: number, callback:AsyncCallback\<void>): void;<br>disconnectAbility(connection: number): Promise\<void>; | 新增 | 14| AbilityContext | AbilityContext | connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; | 新增 | 15| AbilityContext | AbilityContext | connectAbility(want: Want, options: ConnectOptions): number; | 新增 | 16| AbilityContext | AbilityContext | terminateSelfWithResult(parameter: AbilityResult, callback: AsyncCallback\<void>): void;<br>terminateSelfWithResult(parameter: AbilityResult): Promise\<void>; | 新增 | 17| AbilityContext | AbilityContext | terminateSelf(callback: AsyncCallback\<void>): void;<br>terminateSelf(): Promise\<void>; | 新增 | 18| AbilityContext | AbilityContext | startAbilityForResultWithAccount(want: Want, accountId: number, callback: AsyncCallback\<AbilityResult>): void;<br>startAbilityForResultWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\<void>): void;<br>startAbilityForResultWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<AbilityResult>; | 新增 | 19| AbilityContext | AbilityContext | startAbilityForResult(want: Want, callback: AsyncCallback\<AbilityResult>): void;<br>startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback\<AbilityResult>): void;<br>startAbilityForResult(want: Want, options?: StartOptions): Promise\<AbilityResult>; | 新增 | 20| AbilityContext | AbilityContext | startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void;<br>startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\<void>): void;<br>startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<void>; | 新增 | 21| AbilityContext | AbilityContext | startAbilityByCall(want: Want): Promise\<Caller>; | 新增 | 22| AbilityContext | AbilityContext | startAbility(want: Want, callback: AsyncCallback\<void>): void;<br>startAbility(want: Want, options: StartOptions, callback: AsyncCallback\<void>): void;<br>startAbility(want: Want, options?: StartOptions): Promise\<void>; | 新增 | 23| AbilityContext | AbilityContext | config: Configuration; | 新增 | 24| AbilityContext | AbilityContext | currentHapModuleInfo: HapModuleInfo; | 新增 | 25| AbilityContext | AbilityContext | abilityInfo: AbilityInfo; | 新增 | 26| abilityDelegator | AbilityDelegator | doAbilityBackground(ability: Ability, callback: AsyncCallback\<boolean>): void;<br>doAbilityBackground(ability: Ability): Promise\<boolean>; | 新增 | 27| abilityDelegator | AbilityDelegator | doAbilityForeground(ability: Ability, callback: AsyncCallback\<boolean>): void;<br>doAbilityForeground(ability: Ability): Promise\<boolean>; | 新增 | 28| abilityDelegator | AbilityDelegator | startAbility(want: Want, callback: AsyncCallback\<void>): void;<br>startAbility(want: Want): Promise\<void>; | 新增 | 29| abilityDelegator | AbilityDelegator | getCurrentTopAbility(callback: AsyncCallback\<Ability>): void;<br>getCurrentTopAbility(): Promise\<Ability> | 新增 | 30| abilityDelegator | AbilityDelegator | getAbilityState(ability: Ability): number; | 新增 | 31| abilityDelegator | AbilityDelegator | getAppContext(): Context; | 新增 | 32| abilityDelegator | AbilityDelegator | waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<Ability>): void;<br>waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback\<Ability>): void;<br>waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise\<Ability>; | 新增 | 33| abilityDelegator | AbilityDelegator | removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void;<br>removeAbilityMonitor(monitor: AbilityMonitor): Promise\<void>; | 新增 | 34| abilityDelegator | AbilityDelegator | addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback\<void>): void;<br>addAbilityMonitor(monitor: AbilityMonitor): Promise\<void>; | 新增 | 35| abilityMonitor | AbilityMonitor | onWindowStageDestroy?:(data: Ability) => void; | 新增 | 36| abilityMonitor | AbilityMonitor | onWindowStageRestore?:(data: Ability) => void; | 新增 | 37| abilityMonitor | AbilityMonitor | onWindowStageCreate?:(data: Ability) => void; | 新增 | 38| abilityMonitor | AbilityMonitor | onAbilityDestroy?:(data: Ability) => void; | 新增 | 39| abilityMonitor | AbilityMonitor | onAbilityBackground?:(data: Ability) => void; | 新增 | 40| abilityMonitor | AbilityMonitor | onAbilityForeground?:(data: Ability) => void; | 新增 | 41| abilityMonitor | AbilityMonitor | onAbilityCreate?:(data: Ability) => void; | 新增 | 42| abilityMonitor | AbilityMonitor | abilityName: string; | 新增 | 43| AbilityStageContext | AbilityStageContext | config: Configuration; | 新增 | 44| AbilityStageContext | AbilityStageContext | currentHapModuleInfo: HapModuleInfo; | 新增 | 45| AbilityStateData | AbilityStateData | moduleName: string; | 新增 | 46| ApplicationContext | ApplicationContext | unregisterAbilityLifecycleCallback(callbackId: number, callback: AsyncCallback\<void>): void;<br>unregisterAbilityLifecycleCallback(callbackId: number): Promise\<void>; | 新增 | 47| ApplicationContext | ApplicationContext | registerAbilityLifecycleCallback(callback: AbilityLifecycleCallback): number; | 新增 | 48| context | AreaMode | EL2 = 1 | 新增 | 49| context | AreaMode | EL1 = 0 | 新增 | 50| context | Context | createBundleContext(bundleName: string): Context; | 新增 | 51| context | Context | area: AreaMode; | 新增 | 52| context | Context | eventHub: EventHub; | 新增 | 53| context | Context | distributedFilesDir: string; | 新增 | 54| context | Context | bundleCodeDir : string; | 新增 | 55| context | Context | preferencesDir : string; | 新增 | 56| context | Context | databaseDir : string; | 新增 | 57| context | Context | filesDir : string; | 新增 | 58| context | Context | tempDir: string; | 新增 | 59| context | Context | cacheDir: string; | 新增 | 60| context | Context | applicationInfo: ApplicationInfo; | 新增 | 61| context | Context | resourceManager: resmgr.ResourceManager; | 新增 | 62| EventHub | EventHub | emit(event: string, ...args: Object[]): void | 新增 | 63| EventHub | EventHub | off(event: string, callback?: Function): void | 新增 | 64| EventHub | EventHub | on(event: string, callback: Function): void | 新增 | 65| extensionAbilityInfo | ExtensionAbilityInfo | readonly writePermission: string; | 新增 | 66| extensionAbilityInfo | ExtensionAbilityInfo | readonly readPermission: string; | 新增 | 67| extensionAbilityInfo | ExtensionAbilityInfo | readonly enabled: boolean; | 新增 | 68| extensionAbilityInfo | ExtensionAbilityInfo | readonly metadata: Array\<Metadata>; | 新增 | 69| extensionAbilityInfo | ExtensionAbilityInfo | readonly applicationInfo: ApplicationInfo; | 新增 | 70| extensionAbilityInfo | ExtensionAbilityInfo | readonly permissions: Array\<string>; | 新增 | 71| extensionAbilityInfo | ExtensionAbilityInfo | readonly extensionAbilityType: bundle.ExtensionAbilityType; | 新增 | 72| extensionAbilityInfo | ExtensionAbilityInfo | readonly isVisible: boolean; | 新增 | 73| extensionAbilityInfo | ExtensionAbilityInfo | readonly iconId: number; | 新增 | 74| extensionAbilityInfo | ExtensionAbilityInfo | readonly descriptionId: number; | 新增 | 75| extensionAbilityInfo | ExtensionAbilityInfo | readonly labelId: number; | 新增 | 76| extensionAbilityInfo | ExtensionAbilityInfo | readonly name: string; | 新增 | 77| extensionAbilityInfo | ExtensionAbilityInfo | readonly moduleName: string; | 新增 | 78| extensionAbilityInfo | ExtensionAbilityInfo | readonly bundleName: string; | 新增 | 79| ExtensionContext | ExtensionContext | config: Configuration; | 新增 | 80| ExtensionContext | ExtensionContext | currentHapModuleInfo: HapModuleInfo; | 新增 | 81| ExtensionRunningInfo | ExtensionRunningInfo | type: bundle.ExtensionAbilityType; | 新增 | 82| ExtensionRunningInfo | ExtensionRunningInfo | clientPackage: Array\<String>; | 新增 | 83| ExtensionRunningInfo | ExtensionRunningInfo | startTime: number; | 新增 | 84| ExtensionRunningInfo | ExtensionRunningInfo | processName: string; | 新增 | 85| ExtensionRunningInfo | ExtensionRunningInfo | uid: number; | 新增 | 86| ExtensionRunningInfo | ExtensionRunningInfo | pid: number; | 新增 | 87| ExtensionRunningInfo | ExtensionRunningInfo | extension: ElementName; | 新增 | 88| FormExtensionContext | FormExtensionContext | updateForm(formId: string, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback\<void>): void;<br>updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Promise\<void>; | 新增 | 89| MissionListener | MissionListener | onMissionIconUpdated(mission: number, icon: image.PixelMap): void; | 新增 | 90| ohos.application.Ability | Ability | dump(params: Array\<string>): Array\<string>; | 新增 | 91| ohos.application.Ability | Ability | onConfigurationUpdated(config: Configuration): void; | 新增 | 92| ohos.application.Ability | Ability | onNewWant(want: Want): void; | 新增 | 93| ohos.application.Ability | Ability | onContinue(wantParam : {[key: string]: any}): AbilityConstant.OnContinueResult; | 新增 | 94| ohos.application.Ability | Ability | onBackground(): void; | 新增 | 95| ohos.application.Ability | Ability | onForeground(): void; | 新增 | 96| ohos.application.Ability | Ability | onDestroy(): void; | 新增 | 97| ohos.application.Ability | Ability | onWindowStageRestore(windowStage: window.WindowStage): void; | 新增 | 98| ohos.application.Ability | Ability | onWindowStageDestroy(): void; | 新增 | 99| ohos.application.Ability | Ability | onWindowStageCreate(windowStage: window.WindowStage): void; | 新增 | 100| ohos.application.Ability | Ability | onCreate(want: Want, param: AbilityConstant.LaunchParam): void; | 新增 | 101| ohos.application.Ability | Ability | callee: Callee; | 新增 | 102| ohos.application.Ability | Ability | lastRequestWant: Want; | 新增 | 103| ohos.application.Ability | Ability | launchWant: Want; | 新增 | 104| ohos.application.Ability | Ability | context: AbilityContext; | 新增 | 105| ohos.application.Ability | Callee | off(method: string): void; | 新增 | 106| ohos.application.Ability | Callee | on(method: string, callback: CaleeCallBack): void; | 新增 | 107| ohos.application.Ability | Caller | onRelease(callback: OnReleaseCallBack): void; | 新增 | 108| ohos.application.Ability | Caller | release(): void; | 新增 | 109| ohos.application.Ability | Caller | callWithResult(method: string, data: rpc.Sequenceable): Promise<rpc.MessageParcel>; | 新增 | 110| ohos.application.Ability | Caller | call(method: string, data: rpc.Sequenceable): Promise\<void>; | 新增 | 111| ohos.application.Ability | CaleeCallBack | (indata: rpc.MessageParcel): rpc.Sequenceable; | 新增 | 112| ohos.application.Ability | OnReleaseCallBack | (msg: string): void; | 新增 | 113| ohos.application.AbilityConstant | OnContinueResult | MISMATCH = 2 | 新增 | 114| ohos.application.AbilityConstant | OnContinueResult | REJECT = 1 | 新增 | 115| ohos.application.AbilityConstant | OnContinueResult | AGREE = 0 | 新增 | 116| ohos.application.AbilityConstant | LastExitReason | NORMAL = 2 | 新增 | 117| ohos.application.AbilityConstant | LastExitReason | ABILITY_NOT_RESPONDING = 1 | 新增 | 118| ohos.application.AbilityConstant | LastExitReason | UNKNOWN = 0 | 新增 | 119| ohos.application.AbilityConstant | LaunchReason | CONTINUATION = 3 | 新增 | 120| ohos.application.AbilityConstant | LaunchReason | CALL = 2 | 新增 | 121| ohos.application.AbilityConstant | LaunchReason | START_ABILITY = 1 | 新增 | 122| ohos.application.AbilityConstant | LaunchReason | UNKNOWN = 0 | 新增 | 123| ohos.application.AbilityConstant | LaunchParam | lastExitReason: LastExitReason; | 新增 | 124| ohos.application.AbilityConstant | LaunchParam | launchReason: LaunchReason; | 新增 | 125| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onAbilityContinue(ability: Ability): void; | 新增 | 126| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onAbilityBackground(ability: Ability): void; | 新增 | 127| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onAbilityForeground(ability: Ability): void; | 新增 | 128| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onAbilityDestroy(ability: Ability): void; | 新增 | 129| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onWindowStageCreate(ability: Ability, windowStage: window.WindowStage): void; | 新增 | 130| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onWindowStageActive(ability: Ability, windowStage: window.WindowStage): void; | 新增 | 131| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onWindowStageInactive(ability: Ability, windowStage: window.WindowStage): void; | 新增 | 132| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onWindowStageDestroy(ability: Ability, windowStage: window.WindowStage): void; | 新增 | 133| ohos.application.AbilityLifecycleCallback | AbilityLifecycleCallback | onAbilityCreate(ability: Ability): void; | 新增 | 134| ohos.application.abilityManager | abilityManager | function getTopAbility(): Promise\<ElementName>;<br>function getTopAbility(callback: AsyncCallback\<ElementName>): void; | 新增 | 135| ohos.application.abilityManager | abilityManager | function getExtensionRunningInfos(upperLimit: number): Promise\<Array\<ExtensionRunningInfo>>;<br>function getExtensionRunningInfos(upperLimit: number, callback: AsyncCallback\<Array\<ExtensionRunningInfo>>): void; | 新增 | 136| ohos.application.AbilityStage | AbilityStage | onConfigurationUpdated(config: Configuration): void; | 新增 | 137| ohos.application.AbilityStage | AbilityStage | onAcceptWant(want: Want): string; | 新增 | 138| ohos.application.AbilityStage | AbilityStage | onCreate(): void; | 新增 | 139| ohos.application.AbilityStage | AbilityStage | context: AbilityStageContext; | 新增 | 140| ohos.application.Configuration | Configuration | displayId?: number; | 新增 | 141| ohos.application.Configuration | Configuration | screenDensity?: ConfigurationConstant.ScreenDensity; | 新增 | 142| ohos.application.Configuration | Configuration | direction?: ConfigurationConstant.Direction; | 新增 | 143| ohos.application.ConfigurationConstant | ScreenDensity | SCREEN_DENSITY_XXXLDPI = 640 | 新增 | 144| ohos.application.ConfigurationConstant | ScreenDensity | SCREEN_DENSITY_XXLDPI = 480 | 新增 | 145| ohos.application.ConfigurationConstant | ScreenDensity | SCREEN_DENSITY_XLDPI = 320 | 新增 | 146| ohos.application.ConfigurationConstant | ScreenDensity | SCREEN_DENSITY_LDPI = 240 | 新增 | 147| ohos.application.ConfigurationConstant | ScreenDensity | SCREEN_DENSITY_MDPI = 160 | 新增 | 148| ohos.application.ConfigurationConstant | ScreenDensity | SCREEN_DENSITY_SDPI = 120 | 新增 | 149| ohos.application.ConfigurationConstant | ScreenDensity | SCREEN_DENSITY_NOT_SET = 0 | 新增 | 150| ohos.application.ConfigurationConstant | Direction | DIRECTION_HORIZONTAL = 1 | 新增 | 151| ohos.application.ConfigurationConstant | Direction | DIRECTION_VERTICAL = 0 | 新增 | 152| ohos.application.ConfigurationConstant | Direction | DIRECTION_NOT_SET = -1 | 新增 | 153| ohos.application.FormExtension | FormExtension | onAcquireFormState?(want: Want): formInfo.FormState; | 新增 | 154| ohos.application.FormExtension | FormExtension | onConfigurationUpdated(config: Configuration): void; | 新增 | 155| ohos.application.FormExtension | FormExtension | onDestroy(formId: string): void; | 新增 | 156| ohos.application.FormExtension | FormExtension | onEvent(formId: string, message: string): void; | 新增 | 157| ohos.application.FormExtension | FormExtension | onVisibilityChange(newStatus: { [key: string]: number }): void; | 新增 | 158| ohos.application.FormExtension | FormExtension | onUpdate(formId: string): void; | 新增 | 159| ohos.application.FormExtension | FormExtension | onCastToNormal(formId: string): void; | 新增 | 160| ohos.application.FormExtension | FormExtension | onCreate(want: Want): formBindingData.FormBindingData; | 新增 | 161| ohos.application.FormExtension | FormExtension | context: FormExtensionContext; | 新增 | 162| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | dump(params: Array\<string>): Array\<string>; | 新增 | 163| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | onConfigurationUpdated(config: Configuration): void; | 新增 | 164| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | onReconnect(want: Want): void; | 新增 | 165| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | onDisconnect(want: Want): void; | 新增 | 166| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | onConnect(want: Want): rpc.RemoteObject; | 新增 | 167| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | onRequest(want: Want, startId: number): void; | 新增 | 168| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | onDestroy(): void; | 新增 | 169| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | onCreate(want: Want): void; | 新增 | 170| ohos.application.ServiceExtensionAbility | ServiceExtensionAbility | context: ServiceExtensionContext; | 新增 | 171| ohos.application.StartOptions | StartOptions | displayId?: number; | 新增 | 172| ohos.application.StartOptions | StartOptions | windowMode?: number; | 新增 | 173| ohos.application.StaticSubscriberExtensionAbility | StaticSubscriberExtensionAbility | onReceiveEvent(event: CommonEventData): void; | 新增 | 174| ohos.application.uriPermissionManager | uriPermissionManager | function verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number, callback: AsyncCallback\<number>): void;<br>function verifyUriPermission(uri: string, flag: wantConstant.Flags, accessTokenId: number): Promise\<number>; | 新增 | 175| ohos.application.WindowExtensionAbility | WindowExtensionAbility | onWindowReady(window: Window): void; | 新增 | 176| ohos.application.WindowExtensionAbility | WindowExtensionAbility | onDisconnect(want: Want): void; | 新增 | 177| ohos.application.WindowExtensionAbility | WindowExtensionAbility | onConnect(want: Want): rpc.RemoteObject; | 新增 | 178| ohos.application.WindowExtensionAbility | WindowExtensionAbility | context: ExtensionContext; | 新增 | 179| ohos.wantAgent | wantAgent | function getOperationType(agent: WantAgent, callback: AsyncCallback\<number>): void;<br>function getOperationType(agent: WantAgent): Promise\<number>; | 新增 | 180| PermissionRequestResult | PermissionRequestResult | authResults: Array\<number>; | 新增 | 181| PermissionRequestResult | PermissionRequestResult | permissions: Array\<string>; | 新增 | 182| ServiceExtensionContext | ServiceExtensionContext | disconnectAbility(connection: number, callback:AsyncCallback\<void>): void;<br>disconnectAbility(connection: number): Promise\<void>; | 新增 | 183| ServiceExtensionContext | ServiceExtensionContext | connectAbilityWithAccount(want: Want, accountId: number, options: ConnectOptions): number; | 新增 | 184| ServiceExtensionContext | ServiceExtensionContext | connectAbility(want: Want, options: ConnectOptions): number; | 新增 | 185| ServiceExtensionContext | ServiceExtensionContext | terminateSelf(callback: AsyncCallback\<void>): void;<br>terminateSelf(): Promise\<void>; | 新增 | 186| ServiceExtensionContext | ServiceExtensionContext | startAbilityWithAccount(want: Want, accountId: number, callback: AsyncCallback\<void>): void;<br>startAbilityWithAccount(want: Want, accountId: number, options: StartOptions, callback: AsyncCallback\<void>): void;<br>startAbilityWithAccount(want: Want, accountId: number, options?: StartOptions): Promise\<void>; | 新增 | 187| ServiceExtensionContext | ServiceExtensionContext | startAbility(want: Want, callback: AsyncCallback\<void>): void;<br>startAbility(want: Want, options: StartOptions, callback: AsyncCallback\<void>): void;<br>startAbility(want: Want, options?: StartOptions): Promise\<void>; | 新增 | 188| ServiceExtensionContext | ServiceExtensionContext | extensionAbilityInfo: ExtensionAbilityInfo; | 新增 | 189 190