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

!17683 翻译完成:16809+16909+17385+17418 修复fileio

Merge pull request !17683 from wusongqing/TR16809
......@@ -18,118 +18,145 @@ import Want from '@ohos.app.ability.Want';
| Name | Type | Mandatory| Description |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | string | No | ID of the device running the ability. |
| bundleName | string | No | Bundle name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. |
| deviceId | string | No | ID of the device running the ability. If this field is unspecified, the local device is used. |
| bundleName | string | No | Bundle name of the ability.|
| moduleName | string | No| Name of the module to which the ability belongs.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | string | No| If **uri** is specified in a **Want**, the **Want** will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path** components.|
| type | string | No| MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.|
| flags | number | No| How the **Want** object will be handled. By default, a number is passed in. For details, see [flags](js-apis-app-ability-wantConstant.md#wantconstantflags). |
| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. |
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br/>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br/>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. For details about the definition and matching rules of implicit Want, see [Matching Rules of Explicit Want and Implicit Want](../../application-models/explicit-implicit-want-mappings.md). |
| entities | Array\<string> | No| Additional category information (such as browser and video player) of the ability. It is a supplement to the **action** field for implicit Want. and is used to filter ability types.|
| moduleName | string | 否 | Module to which the ability belongs. |
| uri | string | No| Data carried. This field is used together with **type** to specify the data type. If **uri** is specified in a Want, the Want will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | string | No| MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com.|
| parameters | {[key: string]: any} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerBundleName**: bundle name of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [BundleInfo](js-apis-bundleManager-bundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files.|
| [flags](js-apis-ability-wantConstant.md#wantconstantflags) | number | No| How the **Want** object will be handled. By default, a number is passed in.<br>For example, **wantConstant.Flags.FLAG_ABILITY_CONTINUATION** specifies whether to start the ability in cross-device migration scenarios.|
**Example**
- Basic usage
- Basic usage: called in a UIAbility object, as shown in the example below. For details about how to obtain the context, see [Obtaining the Context of UIAbility](../../application-models/uiability-usage.md#obtaining-the-context-of-uiability).
```ts
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.extreme.test',
'abilityName': 'MainAbility',
'moduleName': 'entry' // moduleName is optional
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log('error.code = ' + error.code);
})
let context = ...; // UIAbilityContext
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.example.myapplication',
'abilityName': 'FuncAbility',
'moduleName': 'entry' // moduleName is optional.
};
context.startAbility(want, (err) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
- Data is transferred through user-defined fields. The following data types are supported:
- Currently, the following data types are supported: string, number, Boolean, object, array, and file descriptor (FD).
* String
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.demo',
abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForString: 'str',
},
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForString: 'str',
},
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* Number
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.demo',
abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForInt: 100,
keyForDouble: 99.99,
},
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* Boolean
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.demo',
abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForBool: true,
},
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForBool: true,
},
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* Object
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.demo',
abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForObject: {
keyForObjectString: 'str',
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForObject: {
keyForObjectString: 'str',
keyForObjectInt: -200,
keyForObjectDouble: 35.5,
keyForObjectBool: false,
},
},
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* Array
```ts
let context = ...; // UIAbilityContext
let want = {
bundleName: 'com.example.demo',
abilityName: 'com.example.demo.MainAbility',
parameters: {
keyForArrayString: ['str1', 'str2', 'str3'],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
keyForArrayObject: [{obj1: 'aaa'}, {obj2: 100}],
},
bundleName: 'com.example.myapplication',
abilityName: 'FuncAbility',
parameters: {
keyForArrayString: ['str1', 'str2', 'str3'],
keyForArrayInt: [100, 200, 300, 400],
keyForArrayDouble: [0.1, 0.2],
keyForArrayObject: [{ obj1: 'aaa' }, { obj2: 100 }],
},
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
* File descriptor (FD)
* FD
```ts
import fileio from '@ohos.fileio';
let fd;
try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
} catch(e) {
console.log('openSync fail:' + JSON.stringify(e));
}
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.extreme.test',
'abilityName': 'MainAbility',
'moduleName': 'entry', // moduleName is optional.
'parameters': {
'keyFd':{'type':'FD', 'value':fd} // {'type':'FD', 'value':fd} is a fixed usage, indicating that the data is a file descriptor.
}
};
this.context.startAbility(want, (error) => {
// Start an ability explicitly. The bundleName, abilityName, and moduleName parameters work together to uniquely identify an ability.
console.log('error.code = ' + error.code);
});
import fs from '@ohos.file.fs';
let context = ...; // UIAbilityContext
let fd;
try {
fd = fs.openSync('/data/storage/el2/base/haps/pic.png').fd;
} catch(err) {
console.error(`Failed to openSync. Code: ${err.code}, message: ${err.message}`);
}
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.example.myapplication',
'abilityName': 'FuncAbility',
'moduleName': 'entry', // moduleName is optional.
'parameters': {
'keyFd': { 'type': 'FD', 'value': fd } // {'type':'FD', 'value':fd} is a fixed usage, indicating that the data is a file descriptor.
}
};
context.startAbility(want, (err) => {
console.error(`Failed to startAbility. Code: ${err.code}, message: ${err.message}`);
});
```
......@@ -19,7 +19,7 @@ import Want from '@ohos.application.Want';
| Name | Type | Mandatory| Description |
| ----------- | -------------------- | ---- | ------------------------------------------------------------ |
| deviceId | string | No | ID of the device running the ability. |
| bundleName | string | No | Bundle name. If both **bundleName** and **abilityName** are specified in a bWantb, the **Want** can directly match the specified ability.|
| bundleName | string | No | Bundle name. If both **bundleName** and **abilityName** are specified in a **Want**, the **Want** can directly match the specified ability.|
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | string | No | URI information to match. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
......@@ -108,10 +108,10 @@ import Want from '@ohos.application.Want';
```
* File descriptor (FD)
```ts
import fileio from '@ohos.fileio';
import fs from '@ohos.file.fs';
let fd;
try {
fd = fileio.openSync('/data/storage/el2/base/haps/pic.png');
fd = fs.openSync('/data/storage/el2/base/haps/pic.png').fd;
} catch(e) {
console.log('openSync fail:' + JSON.stringify(e));
}
......
......@@ -15,9 +15,9 @@ Want is a carrier for information transfer between objects (application componen
| abilityName | string | No | Name of the ability. If both **bundleName** and **abilityName** are specified in a **Want** object, the **Want** object can match a specific ability. The value of **abilityName** must be unique in an application.|
| uri | string | No | URI. If **uri** is specified in a **Want** object, the **Want** object will match the specified URI information, including **scheme**, **schemeSpecificPart**, **authority**, and **path**.|
| type | string | No | MIME type, that is, the type of the file to open, for example, **'text/xml'** and **'image/*'**. For details about the MIME type definition, see https://www.iana.org/assignments/media-types/media-types.xhtml?utm_source=ld246.com. |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-app-ability-wantConstant.md#wantconstantflags). |
| flags | number | No | How the **Want** object will be handled. By default, numbers are passed in. For details, see [flags](js-apis-ability-wantConstant.md#wantconstantflags).|
| action | string | No | Action to take, such as viewing and sharing application details. In implicit Want, you can define this field and use it together with **uri** or **parameters** to specify the operation to be performed on the data. |
| parameters | {[key: string]: Object} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>**ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| parameters | {[key: string]: Object} | No | Want parameters in the form of custom key-value (KV) pairs. By default, the following keys are carried:<br>- **ohos.aafwk.callerPid**: PID of the caller.<br>- **ohos.aafwk.param.callerToken**: token of the caller.<br>- **ohos.aafwk.param.callerUid**: UID in [bundleInfo](js-apis-bundle-BundleInfo.md#bundleinfo-1), that is, the application UID in the bundle information.<br>- **component.startup.newRules**: whether to enable the new control rule.<br>- **moduleName**: module name of the caller. No matter what this field is set to, the correct module name will be sent to the peer.<br>- **ohos.dlp.params.sandbox**: available only for DLP files. |
| entities | Array\<string> | No | Additional category information (such as browser and video player) of the target ability. It is a supplement to **action** in implicit Want and is used to filter ability types. |
| moduleName<sup>9+</sup> | string | No | Module to which the ability belongs.|
......@@ -52,8 +52,8 @@ Want is a carrier for information transfer between objects (application componen
}
let want = {
'deviceId': '', // An empty deviceId indicates the local device.
'bundleName': 'com.example.myapplication',
'abilityName': 'EntryAbility',
'bundleName': 'com.extreme.test',
'abilityName': 'MainAbility',
'moduleName': 'entry', // moduleName is optional.
'parameters': {
'keyFd':{'type':'FD', 'value':fd}
......@@ -66,5 +66,5 @@ Want is a carrier for information transfer between objects (application componen
// ...
```
- For more details and examples, see [Want](../../application-models/application-model-composition.md).
- For more details and examples, see [Want](../../application-models/want-overview.md).
......@@ -186,6 +186,24 @@ The context passed in the API does not exist.
Use the correct context.
## 16000017 Waiting for the Previous Abilities to Finish Startup
**Error Message**
The previous ability is starting, wait start later.
**Description**
Too many abilities need to be started. Due to the limited processing capability of the system, the requests are cached in the queue and processed in sequence.
**Possible Causes**
The system has a large number of concurrent requests.
**Solution**
No action is required. Wait for the previous abilities to finish startup.
## 100001 Internal Error
**Error Message**
......@@ -706,7 +724,7 @@ Internal error.
**Description**
This error code is returned when an error occurs during internal processing, such as memory application or multi-thread processing.
This error code is reported when an error occurs during internal processing, such as memory application or multi-thread processing.
**Possible Causes**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册