未验证 提交 c63300fd 编写于 作者: O openharmony_ci 提交者: Gitee

!21011 【资料问题】元能力文档接口一致性和示例代码问题

Merge pull request !21011 from yuyaozhi/master
......@@ -13,6 +13,8 @@ Ability模块将二级模块API组织在一起方便开发者进行导出。
import ability from '@ohos.ability.ability';
```
## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 类型 | 描述 |
......
......@@ -14,7 +14,7 @@ import common from '@ohos.app.ability.common';
```
## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 名称 | 类型 | 说明 |
| ----------- | -------------------- | ------------------------------------------------------------ |
......
......@@ -64,21 +64,13 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>, callback: AsyncCallback\<v
**错误码**
在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。
| 错误码ID | 错误信息 |
| ------- | -------- |
| 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. |
| 18500008 | Internal error. |
在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下:
| 错误码ID | 错误信息 |
| ------- | -------- |
| 18500003 | Deploy hqf failed. |
| 18500004 | Switch hqf failed. |
| 18500005 | Delete hqf failed. |
| 18500006 | Load patch failed. |
| 18500007 | Unload patch failed. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
> 说明:调用applyQuickFix接口时,补丁文件所在路径为应用沙箱路径。沙箱路径的获取参考[获取应用的沙箱路径](js-apis-bundle-BundleInstaller.md#获取应用的沙箱路径),映射到设备上的路径为/proc/&lt;应用进程Id&gt;/root/沙箱路径。
......@@ -126,21 +118,13 @@ applyQuickFix(hapModuleQuickFixFiles: Array\<string>): Promise\<void>;
**错误码**
在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。
| 错误码ID | 错误信息 |
| ------- | -------- |
| 18500002 | The specified quick fix is invalid. It may not exist or inaccessible. |
| 18500008 | Internal error. |
在打补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_APPLY_RESULT](commonEvent-definitions.md#common_event_quick_fix_apply_result9)的参数返回给应用开发者。这部分错误码及错误信息如下:
| 错误码ID | 错误信息 |
| ------- | -------- |
| 18500003 | Deploy hqf failed. |
| 18500004 | Switch hqf failed. |
| 18500005 | Delete hqf failed. |
| 18500006 | Load patch failed. |
| 18500007 | Unload patch failed. |
以上错误码详细介绍请参考[errcode-ability](../errorcodes/errorcode-ability.md)
**示例:**
......@@ -279,13 +263,7 @@ revokeQuickFix(bundleName: string, callback: AsyncCallback\<void>): void;
| 18500001 | The bundle is not exist or no patch has applied. |
| 18500009 | The application has a apply quick fix task that is being processed. |
在撤销补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_REVOKE_RESULT](./common_event/commonEvent-ability.md#common_event_quick_fix_revoke_result10)的参数返回给应用开发者。这部分错误码及错误信息如下:
| 错误码ID | 错误信息 |
| ------- | -------- |
| 18500004 | Switch hqf failed. |
| 18500005 | Delete hqf failed. |
| 18500007 | Unload patch failed. |
在撤销补丁过程中发生的错误,其错误码及错误信息通过公共事件[COMMON_EVENT_QUICK_FIX_REVOKE_RESULT](./common_event/commonEvent-ability.md#common_event_quick_fix_revoke_result10)的参数返回给应用开发者。
**示例:**
......
......@@ -171,6 +171,7 @@ import Want from '@ohos.app.ability.Want';
```ts
// (1) UIAbility1启动一个ServiceExtension
import common from '@ohos.app.ability.common';
let context = getContext(this) as common.UIAbilityContext; // UIAbilityContext
let want = {
bundleName: 'com.example.myapplication1',
......
......@@ -74,15 +74,4 @@ try {
} catch (error) {
console.error(`catch error, code: ${error.code}, message: ${error.message}`);
}
```
## ProxyData
定义表单代理数据。
**系统能力**:SystemCapability.Ability.Form
| 名称 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| key | string | 是 | 代理的密钥。值取决于数据发布者。|
| subscriberId | string | 否 | 订阅者ID。值取决于数据发布者。默认值为当前卡片ID。|
\ No newline at end of file
```
\ No newline at end of file
......@@ -169,6 +169,8 @@ import formInfo from '@ohos.app.form.formInfo';
**系统能力**:SystemCapability.Ability.Form
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------- | -------- | -------- | -------------------- | ------------------------------------------------------------ |
| bundleName | string | 是 | 否 | 提供方卡片所属包的Bundle名称。 |
......
......@@ -37,7 +37,7 @@ startAbility(want: Want, callback: AsyncCallback&lt;void&gt;): void;
- 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限
- 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES
**需要权限**:ohos.permission.START_ABILITIES_FROM_BACKGROUND
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
......@@ -106,7 +106,7 @@ startAbility(want: Want): Promise&lt;void&gt;;
- 调用方应用位于后台时,使用该接口启动Ability需申请`ohos.permission.START_ABILITIES_FROM_BACKGROUND`权限
- 跨应用场景下,目标Ability的visible属性若配置为false,调用方应用需申请`ohos.permission.START_INVISIBLE_ABILITY`权限
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES
**需要权限**:ohos.permission.START_ABILITIES_FROM_BACKGROUND
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
......
......@@ -404,7 +404,7 @@ killProcessWithAccount(bundleName: string, accountId: number): Promise\<void\>
>
> 当accountId为当前用户时,不需要校验ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS权限。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES, ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**需要权限**:ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS, ohos.permission.CLEAN_BACKGROUND_PROCESSES
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
......@@ -446,7 +446,7 @@ killProcessWithAccount(bundleName: string, accountId: number, callback: AsyncCal
**系统API**: 此接口为系统接口,三方应用不支持调用。
**需要权限**:ohos.permission.CLEAN_BACKGROUND_PROCESSES, ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**需要权限**:ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS, ohos.permission.CLEAN_BACKGROUND_PROCESSES
**参数:**
......
......@@ -26,7 +26,7 @@ import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
此枚举值用于标识过滤条件类型。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.BundleManager.BundleFramework.Core
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
**系统API:** 此接口为系统接口。
......@@ -39,7 +39,7 @@ import businessAbilityRouter from '@ohos.app.businessAbilityRouter';
此过滤值用于过滤查询的ability类型。
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统能力:** SystemCapability.Ability.AbilityRuntime.Core
**系统API:** 此接口为系统接口。
......@@ -57,7 +57,7 @@ queryBusinessAbilityInfo(filter: BusinessAbilityFilter, callback: AsyncCallback\
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统能力:** SystemCapability.Ability.AbilityRuntime.Core
**系统API:** 此接口为系统接口。
......@@ -94,7 +94,7 @@ queryBusinessAbilityInfo(filter: BusinessAbilityFilter): Promise\<Array\<Busines
**需要权限:** ohos.permission.GET_BUNDLE_INFO_PRIVILEGED
**系统能力:** SystemCapability.BundleManager.BundleFramework.Core
**系统能力:** SystemCapability.Ability.AbilityRuntime.Core
**系统API:** 此接口为系统接口。
......
......@@ -16,8 +16,8 @@ import ability from '@ohos.ability.ability';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityBase
| 名称 | 可读 | 可写 | 类型 | 必填 | 说明 |
| ----------- | -------- |-------- | -------------------- | ---- | ------------------------------------------------------------ |
| resultCode | 是 | 是 | number | 是 | 表示Ability被拉起并退出后返回的结果码。 |
| want | 是 | 是 | [Want](./js-apis-app-ability-want.md) | 否 | 表示Ability被拉起并退出后返回的数据。 |
| 名称 | 类型 | 必填 | 说明 |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| resultCode | number | 是 | 表示Ability被拉起并退出后返回的结果码。 |
| want | [Want](./js-apis-app-ability-want.md) | 否 | 表示Ability被拉起并退出后返回的数据。 |
......@@ -16,7 +16,7 @@ import common from '@ohos.app.ability.common';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
| 参数名 | 类型 | 必填 | 说明 |
| 名称 | 类型 | 必填 | 说明 |
| ------------ | -------- | ---- | ------------------------- |
| onConnect<sup>7+</sup> | function | 是 | 建立连接时的回调函数。 |
| onDisconnect<sup>7+</sup> | function | 是 | 断开连接时的回调函数。 |
......
......@@ -27,7 +27,7 @@ import Want from '@ohos.app.ability.Want';
| action | string | 否 | 表示要执行的通用操作(如:查看、分享、应用详情)。在隐式Want中,您可以定义该字段,配合uri或parameters来表示对数据要执行的操作。具体参考:[action说明](js-apis-ability-wantConstant.md#wantconstantaction)。隐式Want定义及匹配规则参考:[显式Want与隐式Want匹配规则](../../application-models/explicit-implicit-want-mappings.md)。 |
| parameters | {[key: string]: Object} | 否 | 表示WantParams,由开发者自行决定传入的键值对。默认会携带以下key值:<br>ohos.aafwk.callerPid 表示拉起方的pid。<br>ohos.aafwk.param.callerToken 表示拉起方的token。<br>ohos.aafwk.param.callerUid 表示[bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo)中的uid,应用包里应用程序的uid。<br />- component.startup.newRules:表示是否启用新的管控规则。<br />- moduleName:表示拉起方的模块名,该字段的值即使定义成其他字符串,在传递到另一端时会被修改为正确的值。<br />- ohos.dlp.params.sandbox:表示dlp文件才会有。 |
| entities | Array\<string> | 否 | 表示目标Ability额外的类别信息(如:浏览器、视频播放器),在隐式Want中是对action字段的补充。在隐式Want中,您可以定义该字段,来过滤匹配Ability类型。具体参考:[entity说明](js-apis-app-ability-wantConstant.md#wantconstantentity)。 |
| moduleName<sup>9+</sup> | string | 否 | 表示待启动的Ability所属的模块(module)。 |
| moduleName<sup>10+</sup> | string | 否 | 表示待启动的Ability所属的模块(module)。 |
**示例:**
......
......@@ -1231,7 +1231,7 @@ waitAbilityStageMonitor(monitor: AbilityStageMonitor, timeout?: number): Promise
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| monitor | [AbilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md) | 是 | [AbilityStageMonitor](js-apis-inner-application-abilityStageMonitor.md) 实例 |
| timeout | number | | 超时最大等待时间,以毫秒为单位。 |
| timeout | number | | 超时最大等待时间,以毫秒为单位。 |
**返回值:**
......
......@@ -16,6 +16,8 @@ import appManager from '@ohos.application.appManager';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| ----------------------- | ---------| ---- | ---- | ------------------------- |
| pid | number | 是 | 否 | 进程ID。 |
......
......@@ -12,6 +12,8 @@
import appManager from '@ohos.app.ability.appManager';
```
## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
**系统API**:本模块被标记为@systemapi,对三方应用隐藏
......
......@@ -359,7 +359,7 @@ export default class EntryAbility extends UIAbility {
## ApplicationContext.off(type: 'applicationStateChange')<sup>10+</sup>
off(type: 'applicationStateChange'): **void**;
off(type: 'applicationStateChange', callback?: ApplicationStateChangeCallback): **void**;
取消当前应用注册的前后台变化的全部监听。
......@@ -370,6 +370,7 @@ off(type: 'applicationStateChange'): **void**;
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------------- | ---- | -------------------- |
| type | string | 是 | 取消监听事件的类型,必须为'applicationStateChange'。 |
| callback | [ApplicationStateChangeCallback](#js-apis-app-ability-applicationStateChangeCallback.md) | 否 | 对于该事件监听的回调方法,可以对应用从后台切换到前台,以及前台切换到后台分别定义回调。 |
**示例:**
......
......@@ -12,6 +12,8 @@
import appManager from '@ohos.app.ability.appManager';
```
## 属性
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Core
**系统API**:该接口为系统接口,三方应用不支持调用。
......
......@@ -158,7 +158,7 @@ try {
## Context.getGroupDir<sup>10+</sup>
getGroupDir(groupId: string): Promise\<string>;
getGroupDir(dataGroupID: string): Promise\<string>;
通过使用元服务应用中的Group ID获取对应的共享目录,使用Promise异步回调。
......@@ -166,9 +166,9 @@ getGroupDir(groupId: string): Promise\<string>;
**参数:**
| 名称 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------- |
| groupId | string | 是 | 元服务应用项目创建时,系统会指定分配唯一Group ID。 |
| dataGroupID | string | 是 | 元服务应用项目创建时,系统会指定分配唯一Group ID。 |
**返回值:**
......@@ -188,16 +188,19 @@ getGroupDir(groupId: string): Promise\<string>;
```ts
let groupId = "1";
context.getGroupDir(groupId).then(data => {
let getGroupDirContext: common.Context;
try {
getGroupDirContext.getGroupDir(groupId).then(data => {
console.log("getGroupDir result:" + data);
}).catch((err) => {
console.error('error: ${JSON.stringify(err)}');
});
})
} catch (error) {
console.error('getGroupDirContext failed, error.code: ${error.code}, error.message: ${error.message}');
}
```
## Context.getGroupDir<sup>10+</sup>
getGroupDir(groupId: string, callback: AsyncCallback\<string>);
getGroupDir(dataGroupID: string, callback: AsyncCallback\<string>);
通过使用元服务应用中的Group ID获取对应的共享目录,使用callback异步回调。
......@@ -205,9 +208,9 @@ getGroupDir(groupId: string, callback: AsyncCallback\<string>);
**参数:**
| 名称 | 类型 | 必填 | 说明 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------- |
| groupId | string | 是 | 元服务应用项目创建时,系统会指定分配唯一Group ID。 |
| dataGroupID | string | 是 | 元服务应用项目创建时,系统会指定分配唯一Group ID。 |
| callback | AsyncCallback\<string> | 是 | 以callback方式返回对应的共享目录。如果不存在则返回为空,仅支持应用el2加密级别。|
**错误码**
......@@ -221,12 +224,14 @@ getGroupDir(groupId: string, callback: AsyncCallback\<string>);
**示例:**
```ts
context.getGroupDir("1", (err, data) => {
if (err) {
console.error('getGroupDir faile, err: ${JSON.stringify(err)}');
} else {
console.log('getGroupDir result is: ${JSON.stringify(data)}');
}
let getGroupDirContext: common.Context;
getGroupDirContext.getGroupDir("1", (err, data) => {
if (err) {
console.error('getGroupDir faile, err: ${JSON.stringify(err)}');
} else {
console.log('getGroupDir result is: ${JSON.stringify(data)}');
}
});
```
......@@ -10,6 +10,8 @@
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 可读 | 可写 | 说明 |
| -------- | ------ | ---- | ---- | ------- |
| srcDeviceId | string | 是 | 是 | 表示任务迁移源设备ID。 |
......
......@@ -13,6 +13,8 @@
import distributedMissionManager from '@ohos.distributedMissionManager';
```
## 属性
**系统能力**:SystemCapability.Ability.AbilityRuntime.Mission
| 名称 | 类型 | 可读 | 可写 | 说明 |
......
......@@ -28,6 +28,7 @@ import missionManager from '@ohos.app.ability.missionManager';
| label | string | 是 | 是 | 表示任务的标签。 |
| iconPath | string | 是 | 是 | 表示任务的图标路径。 |
| continuable | boolean | 是 | 是 | 表示任务是否可以迁移。 |
| abilityState | number | 是 | 是 | 表示此任务的能力状态。 |
| unclearable<sup>10+</sup> | boolean | 是 | 是 | 表示任务是否可以被用户手动删除。 |
**示例:**
......
......@@ -16,6 +16,8 @@ import missionManager from '@ohos.app.ability.missionManager';
**系统能力**:以下各项对应的系统能力均为SystemCapability.Ability.AbilityRuntime.Mission
**系统API**: 此接口为系统接口,三方应用不支持调用。
| 名称 | 类型 | 必填 | 说明 |
| ----------- | -------- | ---- | ------------------------------------------------------------ |
| onMissionCreated | function | 否 | 表示当系统创建任务时回调执行。 |
......
......@@ -1102,6 +1102,7 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000053 | The ability is not on the top of the UI. |
......@@ -1169,6 +1170,7 @@ connectServiceExtensionAbilityWithAccount(want: Want, accountId: number, options
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000053 | The ability is not on the top of the UI. |
......
......@@ -116,7 +116,6 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback&lt;void&
**错误码:**
| 错误码ID | 错误信息 |
| 错误码ID | 错误信息 |
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
......@@ -276,6 +275,8 @@ startAbilityForResult(want: Want, callback: AsyncCallback&lt;AbilityResult&gt;):
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
......@@ -345,6 +346,8 @@ startAbilityForResult(want: Want, options: StartOptions, callback: AsyncCallback
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
......@@ -424,6 +427,8 @@ startAbilityForResult(want: Want, options?: StartOptions): Promise&lt;AbilityRes
| 16000009 | An ability cannot be started or stopped in Wukong mode. |
| 16000010 | The call with the continuation flag is forbidden. |
| 16000011 | The context does not exist. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 16000050 | Internal error. |
| 16000053 | The ability is not on the top of the UI. |
| 16000055 | Installation-free timed out. |
......@@ -979,6 +984,7 @@ stopServiceExtensionAbility(want: Want, callback: AsyncCallback\<void>): void;
| ------- | -------------------------------- |
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000011 | The context does not exist. |
......@@ -1040,8 +1046,6 @@ stopServiceExtensionAbility(want: Want): Promise\<void>;
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000011 | The context does not exist. |
| 16000012 | The application is controlled. |
| 16000013 | The application is controlled by EDM. |
| 16000050 | Internal error. |
| 16200001 | The caller has been released. |
......@@ -1445,6 +1449,7 @@ connectServiceExtensionAbility(want: Want, options: ConnectOptions): number;
| 16000001 | The specified ability does not exist. |
| 16000002 | Incorrect ability type. |
| 16000004 | Can not start invisible component. |
| 16000005 | The specified process does not have the permission. |
| 16000006 | Cross-user operations are not allowed. |
| 16000008 | The crowdtesting application expires. |
| 16000053 | The ability is not on the top of the UI. |
......@@ -2226,7 +2231,7 @@ setMissionContinueState(state: AbilityConstant.ContinueState, callback:AsyncCall
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| state | [ContinueState](js-apis-app-ability-abilityConstant.md#abilityconstantcontinuestate10) | 是 | 流转状态。 |
| state | [AbilityConstant.ContinueState](js-apis-app-ability-abilityConstant.md#abilityconstantcontinuestate10) | 是 | 流转状态。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数,返回接口调用是否成功的结果。 |
**错误码:**
......@@ -2260,7 +2265,7 @@ setMissionContinueState(state: AbilityConstant.ContinueState): Promise&lt;void&g
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| state | [ContinueState](js-apis-app-ability-abilityConstant.md#abilityconstantcontinuestate10) | 是 | 流转状态。 |
| state | [AbilityConstant.ContinueState](js-apis-app-ability-abilityConstant.md#abilityconstantcontinuestate10) | 是 | 流转状态。 |
**返回值:**
......@@ -2787,9 +2792,9 @@ startAbilityByCallWithAccount(want: Want, accountId: number): Promise&lt;Caller&
}
```
## UIAbilityContext.reportDrawnCompleted
## UIAbilityContext.reportDrawnCompleted<sup>10+</sup>
reportDrawnCompleted(callback: AsyncCallback<void>): void;
reportDrawnCompleted(callback: AsyncCallback\<void>): void;
当页面加载完成(loadContent成功)时,为开发者提供打点功能(callback形式)。
**系统能力**:SystemCapability.Ability.AbilityRuntime.Core
......@@ -2812,26 +2817,31 @@ reportDrawnCompleted(callback: AsyncCallback<void>): void;
**示例:**
```ts
onWindowStageCreate(windowStage: Window.WindowStage) {
import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
windowStage.loadContent('pages/Index', (err, data) => {
if (err.code) {
return;
}
try {
this.context.reportDrawnCompleted((err) => {
if (err.code) {
// 处理业务逻辑错误
console.error(`reportDrawnCompleted failed, code is ${err.code}, message is ${err.message}`);
return;
}
// 执行正常业务
console.info('reportDrawnCompleted succeed');
});
} catch (err) {
// 捕获同步的参数错误
if (err.code) {
return;
}
try {
this.context.reportDrawnCompleted((err) => {
if (err.code) {
// 处理业务逻辑错误
console.error(`reportDrawnCompleted failed, code is ${err.code}, message is ${err.message}`);
}
return;
}
// 执行正常业务
console.info('reportDrawnCompleted succeed');
});
} catch (err) {
// 捕获同步的参数错误
console.error(`reportDrawnCompleted failed, code is ${err.code}, message is ${err.message}`);
}
});
console.log("MainAbility onWindowStageCreate")
}
}
};
```
\ No newline at end of file
......@@ -57,18 +57,18 @@ grantUriPermission(uri: string, flag: wantConstant.Flags, targetBundleName: stri
import fileUri from '@ohos.file.fileuri';
let targetBundleName = 'com.example.test_case1'
let path = this.context.filesDir + '/newDir';
await fileio.mkdir(path, function (err) {
let path = "file://com.example.test_case1/data/storage/el2/base/haps/entry_test/files/newDir";
fileio.mkdir(path, function (err) {
if (err) {
hilog.info(0x0000, 'testTag', "mkdir error"+err.message);
console.log("mkdir error"+err.message)
} else {
hilog.info(0x0000, 'testTag', "mkdir succeed");
console.log("mkdir succeed")
}
});
let uri = fileUri.getUriFromPath(path);
uriPermissionManager.grantUriPermission(uri, WantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, targetBundleName, (result) => {
console.log("result.code = " + result.code)
})
console.log("result.code = " + result.code)
})
```
......@@ -119,20 +119,21 @@ grantUriPermission(uri: string, flag: wantConstant.Flags, targetBundleName: stri
import fileUri from '@ohos.file.fileuri';
let targetBundleName = 'com.example.test_case1'
let path = this.context.filesDir + '/newDir';
await fileio.mkdir(path, function (err) {
let path = "file://com.example.test_case1/data/storage/el2/base/haps/entry_test/files/newDir";
fileio.mkdir(path, function (err) {
if (err) {
hilog.info(0x0000, 'testTag', "mkdir error"+err.message);
console.log("mkdir error"+err.message)
} else {
hilog.info(0x0000, 'testTag', "mkdir succeed");
console.log("mkdir succeed")
}
});
let uri = fileUri.getUriFromPath(path);
uriPermissionManager.grantUriPermission(uri, wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, targetBundleName)
.then((data) => {
uriPermissionManager.grantUriPermission(uri, WantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, targetBundleName)
.then((data) => {
console.log('Verification succeeded.' + data)
}).catch((error) => {
console.log('Verification failed.');
}).catch((error) => {
console.log('Verification failed.');
})
```
## uriPermissionManager.revokeUriPermission
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册