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

!2275 帐号+多模文档修改+网站目录更新

Merge pull request !2275 from zengyawen/master
# Sensor Development
## When to Use
- Data provided by the compass sensor denotes the current orientation of the user device, which helps your application accurately navigate for the user.
- Data provided by the proximity sensor denotes the distance between the device and a visible object, which enables the device to automatically turn on or off its screen accordingly to prevent accidental touch on the screen.
- Data provided by the barometer sensor helps your application accurately determine the altitude of the device.
- Data provided by the ambient light sensor helps your device automatically adjust its backlight.
- Data provided by the Hall effect sensor implements the smart cover mode of your device.
- Data provided by the heart rate sensor helps your application track the health of a user.
- Data provided by the pedometer sensor helps your application obtain the number steps a user has walked.
- Data provided by the wear detection sensor helps your application detect whether a user is wearing a wearable device.
## Available APIs
| Module | API | Description |
| -------- | -------- | -------- |
| ohos.sensor | sensor.on(sensorType,callback:AsyncCallback<Response>):void | Subscribes to data changes of a type of sensor. |
| ohos.sensor | sensor.once(sensorType,callback:AsyncCallback<Response>):void | Subscribes to only one data change of a type of sensor. |
| ohos.sensor | sensor.off(sensorType,callback:AsyncCallback<void>):void | Unsubscribes from sensor data changes. |
## How to Develop
1. To obtain data from a type of sensor, configure the request permissions in the **config.json** file.
```
"reqPermissions":[
{
"name":"ohos.permission.ACCELEROMETER",
"reason"":"",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
}
},
{
"name":"ohos.permission.GYROSCOPE",
"reason"":"",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
}
},
{
"name":"ohos.permission.ACTIVITY_MOTION",
"reason"":"ACTIVITY_MOTION_TEST",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
}
},
{
"name":"ohos.permission.READ_HEALTH_DATA",
"reason"":"HEALTH_DATA_TEST",
"usedScene":{
"ability": ["sensor.index.MainAbility",".MainAbility"],
"when":"inuse"
}
},
{
"name":"ohos.permission.VIBRATE",
"reason"":"",
"usedScene":{
"ability": [".MainAbility"],
"when":"inuse"
}
},
]
```
2. Subscribe to data changes of a type of sensor.
```
import sensor from "@ohos.sensor"
sensor.on(type:sensorType,function(error,data){
if (error) {// The call fails, and error.code and error.message are printed.
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
};
console.info("Subscription succeeded. data = "+ data);// The call is successful, and the obtained sensor data is printed.
}
);
```
The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
![en-us_image_0000001241693881](figures/en-us_image_0000001241693881.png)
3. Unsubscribe from sensor data changes.
```
import sensor from "@ohos.sensor"
sensor.off(type:sensorType,function(error) {
if (error) {// The unsubscription fails, and error.code and error.message are printed.
console.error("Failed to unsubscribe from acceleration sensor data. Error code: " + error.code + "; message: " + error.message);
return;
};
console.info("Succeeded in unsubscribing from acceleration sensor data.");// The unsubscription is successful, and the result is printed.
}
);
```
The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
![en-us_image_0000001196654004](figures/en-us_image_0000001196654004.png)
4. Subscribe to only one data change of a type of sensor.
```
import sensor from "@ohos.sensor"
sensor.once(tyep:sensorType,function(error, data) {
if (error) {// The call fails, and error.code and error.message are printed.
console.error("Failed to obtain data. Error code: " + error.code + "; message: " + error.message);
return;
};
console.info("Data obtained successfully. data="+data);// The call is successful, and the obtained sensor data is printed.
}
);
```
The following figure shows the successful call result when **SensorType** is **SENSOR_TYPE_ID_ACCELEROMETER**.
![en-us_image_0000001241733907](figures/en-us_image_0000001241733907.png)
# Sensor Overview
Sensors in OpenHarmony are an abstraction of underlying hardware-based sensors. Your application can access the underlying sensors via OpenHarmony sensors. Using the APIs provided by OpenHarmony sensors, you can query sensors on your device, subscribe to sensor data, customize algorithms based on sensor data, and develop various sensor-based applications, such as compass, fitness and health, and games applications.
The sensors are classified into the following categories based on their functions: motion, environment, orientation, light, body, and other categories (such as Hall effect sensors). Each category includes different sensor types. A sensor type may be a single physical sensor or a composite of multiple physical sensors.
**Table1** Motion - ohos.sensor.agent.CategoryMotionAgent
| Sensor Type | Sensor Name | Description | Usage |
| -------- | -------- | -------- | -------- |
| SENSOR_TYPE_ACCELEROMETER | Acceleration sensor | Measures the acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s<sup>2</sup>. | Detecting the motion status |
| SENSOR_TYPE_ACCELEROMETER_UNCALIBRATED | Uncalibrated acceleration sensor | Measures the uncalibrated acceleration (including the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s<sup>2</sup>. | Measuring the acceleration bias estimation |
| SENSOR_TYPE_LINEAR_ACCELERATION | Linear acceleration sensor | Measures the linear acceleration (excluding the gravity acceleration) applied to a device on three physical axes (X, Y, and Z), in the unit of m/s<sup>2</sup>. | Detecting the linear acceleration in each axis |
| SENSOR_TYPE_GRAVITY | Gravity sensor | Measures the gravity acceleration applied to a device on three physical axes (X, Y, and Z), in the unit of m/s<sup>2</sup>. | Measuring the gravity |
| SENSOR_TYPE_GYROSCOPE | Gyroscope sensor | Measures the rotation angular velocity of a device on three physical axes (X, Y, and Z), in the unit of rad/s. | Measuring the rotation angular velocity |
| SENSOR_TYPE_GYROSCOPE_UNCALIBRATED | Uncalibrated gyroscope sensor | Measures the uncalibrated rotation angular velocity of a device on three physical axes (X, Y, and Z), in the unit of rad/s. | Measuring the bias estimation of the rotation angular velocity |
| SENSOR_TYPE_SIGNIFICANT_MOTION | Significant motion sensor | Checks whether a device has a significant motion on three physical axes (X, Y, and Z). The value can be **0** (having no significant motion) or **1** (having a significant motion). | Detecting significant motions of a device |
| SENSOR_TYPE_DROP_DETECTION | Drop detection sensor | Detects the device drop status. The value can be **0** (the device is not dropped) or **1** (the device is dropped). | Detecting whether a device is dropped |
| SENSOR_TYPE_PEDOMETER_DETECTION | Pedometer detection sensor | Detects whether a user takes a step. The value can be **0** (the user does not take a step) or **1** (the user takes a step). | Detecting whether a user takes a step |
| SENSOR_TYPE_PEDOMETER | Pedometer sensor | Records the number of steps a user has walked. | Providing the number of steps a user has walked |
**Table2** Environment - ohos.sensor.agent.CategoryOrientationAgent
| Sensor Type | Sensor Name | Description | Usage |
| -------- | -------- | -------- | -------- |
| SENSOR_TYPE_AMBIENT_TEMPERATURE | Ambient temperature sensor. | Measures the ambient temperature, in the unit of degree Celsius (°C). | Measuring the ambient temperature |
| SENSOR_TYPE_MAGNETIC_FIELD | Magnetic field sensor | Measures the magnetic field on three physical axes (X, Y, and Z), in the unit of μT. | Creating a compass |
| SENSOR_TYPE_MAGNETIC_FIELD_UNCALIBRATED | Uncalibrated magnetic field sensor | Measures the uncalibrated magnetic field on three physical axes (X, Y, and Z), in the unit of μT. | Measuring the magnetic field bias estimation |
| SENSOR_TYPE_HUMIDITY | Humidity sensor | Measures the ambient relative humidity, in a percentage (%). | Monitoring the dew point, absolute humidity, and relative humidity |
| SENSOR_TYPE_BAROMETER | Barometer sensor | Measures the barometric pressure, in the unit of hPa or mbar. | Measuring the barometric pressure |
| SENSOR_TYPE_SAR | Specific Absorption Rate (SAR) sensor | Measures the SAR, in the unit of W/kg. | Measuring the SAR of electromagnetic waves for a device |
**Table3** Orientation - ohos.sensor.agent.CategoryOrientationAgent
| Sensor Type | Sensor Name | Description | Usage |
| -------- | -------- | -------- | -------- |
| SENSOR_TYPE_6DOF | Degrees of Freedom (DoF) sensor | Measures the forward/backward, up/down, and left/right translational movement of a device on the three axes (X, Y, and Z) in the unit of m or mm as well as the roll, pitch, and yaw rotation angles on the three axes (X, Y, and Z) in the unit of rad. | Positioning an object by detecting its freedom of translational and rotational motions, for example, VR |
| SENSOR_TYPE_SCREEN_ROTATION | Screen rotation sensor | Checks the rotation status of the device screen. | Detecting whether the device screen is rotating |
| SENSOR_TYPE_DEVICE_ORIENTATION | Device orientation sensor | Measures the rotation angles of the device, in the unit of rad. | Measuring the angles that a device has rotated |
| SENSOR_TYPE_ORIENTATION | Orientation sensor | Measures the rotation angles of a device on three physical axes (X, Y, and Z), in the unit of rad. | Providing the three orientation angles of the screen |
| SENSOR_TYPE_ROTATION_VECTOR | Rotation vector sensor | Measures the rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor, magnetic field sensor, and gyroscope sensor. | Detecting the orientation of a device in the East, North, Up (ENU) Cartesian coordinate system |
| SENSOR_TYPE_GAME_ROTATION_VECTOR<br/>SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR | Game rotation vector sensor<br/>Geomagnetic rotation vector sensor | Measures the game rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor and gyroscope sensor.<br/>Measures the geomagnetic rotation vector of a device. It is a composite sensor that generates data from the acceleration sensor and magnetic field sensor. | Applied in games<br/>Measuring the geomagnetic rotation vector |
**Table4** Light - ohos.sensor.agent.CategoryLightAgent
| Sensor Type | Sensor Name | Description | Usage |
| -------- | -------- | -------- | -------- |
| SENSOR_TYPE_PROXIMITY | Proximity sensor | Measures the distance between a visible object and the device screen. | Measuring the distance between a person and the device during a call |
| SENSOR_TYPE_TOF | Time of flight (ToF) sensor | Measures the time required for light to travel a distance in the medium. | Facial recognition |
| SENSOR_TYPE_AMBIENT_LIGHT | Ambient light sensor | Measures the ambient light intensity of a device, in the unit of lux. | Automatically adjusting the screen brightness and checking whether the screen is covered on the top |
| SENSOR_TYPE_COLOR_TEMPERATURE | Color temperature sensor | Measures the ambient color temperature. | Image processing on the device |
| SENSOR_TYPE_COLOR_RGB | RGB color sensor | Measures the ambient RGB color values. | Color detection implemented by the reflectance of RGB colors |
| SENSOR_TYPE_COLOR_XYZ | XYZ color sensor | Measures the ambient XYZ color values. | Identifying true-color spots to reproduce more natural colors |
**Table5** Body - ohos.sensor.agent.CategoryBodyAgent
| Sensor Type | Sensor Name | Description | Usage |
| -------- | -------- | -------- | -------- |
| SENSOR_TYPE_HEART_RATE | Heart rate sensor | Measures the heart rate of a user. | Providing users' heart rate data |
| SENSOR_TYPE_WEAR_DETECTION | Wear detection sensor | Checks whether a user is wearing a wearable device. | Detecting wearables |
**Table6** Others
| Sensor Type | Sensor Name | Description | Usage |
| -------- | -------- | -------- | -------- |
| SENSOR_TYPE_HALL | Hall effect sensor | Detects a magnetic field around a device. | Smart cover mode of the device |
| SENSOR_TYPE_GRIP_DETECTOR | Grip detection sensor | Detects grip force applied on a device. | Detecting whether the device is gripped on its sides |
| SENSOR_TYPE_MAGNET_BRACKET | Magnet bracket sensor | Checks whether a device is magnetized. | Detecting an in-vehicle or indoor device |
| SENSOR_TYPE_PRESSURE_DETECTOR | Pressure detection sensor | Detects pressure force applied on a device. | Detecting pressure on the top of the device |
## How a Service Is Shared Using Huawei Share
The following modules work cooperatively to implement OpenHarmony sensors: Sensor API, Sensor Framework, Sensor Service, and HD_IDL.
**Figure1** Working principles for OpenHarmony sensors
![en-us_image_0000001226521897](figures/en-us_image_0000001226521897.png)
- Sensor API: provides APIs for performing basic operations on sensors, including querying the sensor list, subscribing to or unsubscribing from sensor data, and executing control commands. This module makes application development simpler.
- Sensor Framework: manages sensor data subscription, creates and destroys data channels, subscribes to or unsubscribes from sensor data, and implements communication with the Sensor Service module.
- Sensor Service: interacts with the HD_IDL module to receive, parse, and distribute data, manages foreground and background policies and sensors of a device, and controls sensor permissions.
- HD_IDL: selects proper policies based on the hardware first in first out (FIFO) and frequency, and adapts to different devices.
## Limitations and Constraints
To obtain data of the following sensors, you must claim the required permissions.
**Table7** Sensor data permission
| Sensor | Permission Name | Sensitivity | Permission Description |
| -------- | -------- | -------- | -------- |
| Acceleration sensor, uncalibrated acceleration sensor, and linear acceleration sensor | ohos.permission.ACCELEROMETER | system_grant | Allows your application to subscribe to data of these acceleration-related sensors in the motion category. |
| Gyroscope sensor and uncalibrated gyroscope sensor | ohos.permission.GYROSCOPE | system_grant | Allows your application to subscribe to data of these gyroscope-related sensors in the motion category. |
| Pedometer sensor | ohos.permission.ACTIVITY_MOTION | user_grant | Allows your application to subscribe to the motion status. |
| Heart rate sensor | ohos.permission.READ_HEALTH_DATA | user_grant | Allows your application to read health data. |
The APIs for subscribing to and unsubscribing from sensor data work in pairs. If you do not need sensor data, call the unsubscription API to stop sensor data reporting.
# Combination Key
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```
import inputConsumer from '@ohos.multimodalInput.inputConsumer';
```
## inputConsumer.on
on(type: "key", keyOption: KeyOption, callback: Callback&lt;KeyOption&gt;): void
Enables listening for combination key events. When a combination key event that meets the specified conditions occurs, **keyOption** will be passed as an input parameter to **callback**.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. |
| keyOption | [KeyOption](#keyoption) | Yes | Key option, which specifies the condition for combination key input. |
| callback | Callback&lt;KeyOption&gt; | Yes | Callback function. When a key input event that meets the specified options occurs, **keyOption** will be passed as an input parameter to **callback**. |
**Example**
```
let keyOption = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOption) {
console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey,
"isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration)
}
inputConsumer.on('key', keyOption, callback);
```
## inputConsumer.off
off(type: "key", keyOption: KeyOption, callback: Callback&lt;KeyOption&gt;): void
Stops listening for combination key events.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type of the key input event to listen for. Only **key** is supported. |
| keyOption | [KeyOption](#keyoption) | Yes | Key option passed to the key input event when listening starts. |
| callback | Callback&lt;KeyOption&gt; | Yes | Callback function passed to the key input event with the key option when listening starts. |
**Example**
```
let keyOption = {preKeys: [], finalKey: 3, isFinalKeyDown: true, finalKeyDownDuration: 0}
let callback = function(keyOption) {
console.info("preKeys: " + keyOption.preKeys, "finalKey: " + keyOption.finalKey,
"isFinalKeyDown: " + keyOption.isFinalKeyDown, "finalKeyDownDuration: " + keyOption.finalKeyDownDuration)
}
inputConsumer.off('key', keyOption, callback);
```
## KeyOption
Defines the key options that are met when a combination key input event occurs.
**System capability**: SystemCapability.MultimodalInput.Input.InputConsumer
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| preKeys | Array | Yes | Array of precedent keys. This parameter can be left empty. There is no requirement on the sequence of precedent keys. |
| finalKey | Number | Yes | Final key in the combination key. This parameter cannot be left blank. |
| isFinalKeyDown | boolean | Yes | Indicates whether the final key is pressed or released. By default, the final key is pressed. |
| finalKeyDownDuration | Number | Yes | Duration for pressing the final key. By default, there is no requirement on the duration. |
# Input Device
The input device management module is used to listen for the connection, disconnection, and updates of input devices and display information about input devices. For example, it can be used to listen for mouse insertion and removal and obtain information such as the ID, name, and pointer speed of the mouse.
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
```
import inputDevice from '@ohos.multimodalInput.inputDevice';
```
## inputDevice.getDeviceIds
getDeviceIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
Obtains the IDs of all input devices. This method uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | Yes | Callback used to return the result. |
**Example**
```
data: {
deviceIds: Array,
},
callback: function(ids) {
this.deviceIds = ids;
},
testGetDeviceIds: function () {
console.info("InputDeviceJsTest---start---testGetDeviceIds");
inputDevice.getDeviceIds(this.callback);
console.info("InputDeviceJsTest---end---testGetDeviceIds");
}
```
## inputDevice.getDevice
getDevice(deviceId: number, callback: AsyncCallback&lt;InputDeviceData&gt;): void
Obtains the information about an input device. This method uses an asynchronous callback to return the result.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
**Parameters**
| Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| deviceId | number | Yes | ID of the input device whose information is to be obtained. |
| callback | AsyncCallback&lt;[InputDeviceData](#inputdevicedata)&gt; | Yes | Callback used to return the **InputDeviceData** object. |
**Example**
```
InputDeviceData {
deviceId : 0,
name : "NA",
sources : Array,
axisRanges : Array,
},
callback: function(deviceData) {
this.InputDeviceData = deviceData;
},
testGetDevice: function () {
// The example is used to obtain the information about the device whose ID is 1.
console.info("InputDeviceJsTest---start---testGetDevice");
inputDevice.getDevice(1, this.callback);
console.info("InputDeviceJsTest---end---testGetDevice");
}
```
## InputDeviceData
Defines the information about an input device.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| -------- | -------- | -------- |
| id | number | Unique identifier of an input device. If the same physical device is repeatedly inserted and removed, its ID changes. |
| name | string | Name of the input device. |
| sources | Array&lt;[SourceType](#sourcetype)&gt; | Source types of the input device. For example, if a keyboard is attached with a touchpad, the device has two input sources: keyboard and touchpad. |
## SourceType
Enumerates the input source types.
**System capability**: SystemCapability.MultimodalInput.Input.InputDevice
| Name | Type | Description |
| -------- | -------- | -------- |
| keyboard | string | The input device is a keyboard. |
| touchscreen | string | The input device is a touchscreen. |
| mouse | string | The input device is a mouse. |
| trackball | string | The input device is a trackball. |
| touchpad | string | The input device is a touchpad. |
| joystick | string | The input device is a joystick. |
# Input Monitor
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are system APIs and cannot be called by third-party applications.
## Modules to Import
```
import inputMonitor from '@ohos.multimodalInput.inputMonitor';
```
## Required Permissions
ohos.permission.INPUT_MONITORING
## inputMonitor.on
on(type: "touch", receiver: TouchEventReceiver): void
Starts listening for global input events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Parameter | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;input&nbsp;event.&nbsp;Currently,&nbsp;only&nbsp;**touch**&nbsp;events&nbsp;are&nbsp;supported. |
| receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;touch&nbsp;event. |
**Example**
```
callback: function (value) {
if (checkEvent(value)) {
// The event meets the service requirement and is consumed.
return true;
} else {
// The event does not meet the service requirement and is not consumed.
return false;
}
},
testOn: function () {
console.info("InputMonitorJsTest---start---testOn");
inputMonitor.on(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOn");
}
```
## inputMonitor.off
off(type: "touch", receiver: TouchEventReceiver): void
Stops listening for global input events.
**Required permissions**: ohos.permission.INPUT_MONITORING
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Parameter | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| type | string | Yes | Type&nbsp;of&nbsp;the&nbsp;input&nbsp;event.&nbsp;Currently,&nbsp;only&nbsp;**touch**&nbsp;events&nbsp;are&nbsp;supported. |
| receiver | [TouchEventReceiver](#toucheventreceiver) | No | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;touch&nbsp;event. |
**Example**
```
callback: function (value) {
if (checkEvent(value)) {
// The event meets the service requirement and is consumed.
return true;
} else {
// The event does not meet the service requirement and is not consumed.
return false;
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
```
## TouchEventReceiver
Represents the class of the callback used to return the touch event. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the opposite.
### (touchEvent: TouchEvent): Boolean
Represents the callback used to return the touch event. You need to define the name of the callback function in the correct format. Ensure that the input parameter is of the **TouchEvent** type, and the return value is of the **Boolean** type.
**System capability**: SystemCapability.MultimodalInput.Input.InputMonitor
**Parameters**
| Parameter | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | Yes | Callback&nbsp;used&nbsp;to&nbsp;return&nbsp;the&nbsp;touch&nbsp;event. |
**Return value**
| Type | Description |
| -------- | -------- |
| Boolean | Result&nbsp;indicating&nbsp;whether&nbsp;the&nbsp;touch&nbsp;event&nbsp;has&nbsp;been&nbsp;consumed&nbsp;by&nbsp;the&nbsp;input&nbsp;monitor.&nbsp;The&nbsp;value&nbsp;**true**&nbsp;indicates&nbsp;that&nbsp;the&nbsp;touch&nbsp;event&nbsp;has&nbsp;been&nbsp;consumed,&nbsp;and&nbsp;the&nbsp;value&nbsp;**false**&nbsp;indicates&nbsp;the&nbsp;opposite. |
**Example**
```
callback: function (value) {// Implementation of the (touchEvent:TouchEvent): Boolean API.
if (checkEvent(value)) {
// The event meets the service requirement and is consumed.
return true;
} else {
// The event does not meet the service requirement and is not consumed.
return false;
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
```
# Learn About OpenHarmony
- [OpenHarmony Project](OpenHarmony-Overview.md)
- [Glossary](device-dev/glossary/glossary.md)
- OpenHarmony Release Notes
- OpenHarmony 3.x Releases
- [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md)
- [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md)
- [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md)
- OpenHarmony 2.x Releases
- [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md)
- [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md)
- OpenHarmony 1.x Releases
- [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md)
- [OpenHarmony v1.1.3 LTS (2021-09-30)](release-notes/OpenHarmony-v1-1-3-LTS.md)
- [OpenHarmony v1.1.2 LTS (2021-08-04)](release-notes/OpenHarmony-v1.1.2-LTS.md)
- [OpenHarmony 1.1.1 LTS (2021-06-22)](release-notes/OpenHarmony-1-1-1-LTS.md)
- [OpenHarmony 1.1.0 LTS (2021-04-01)](release-notes/OpenHarmony-1-1-0-LTS.md)
- [OpenHarmony 1.0 (2020-09-10)](release-notes/OpenHarmony-1-0.md)
- Contribution
- [Contribution](contribute/contribution.md)
- [Code of Conduct](contribute/code-of-conduct.md)
- [Code Contribution](contribute/code-contribution.md)
- [Contribution Process](contribute/contribution-process.md)
- [Auto-Test](readme/test_subsystem.md)
- [Documentation Contribution](contribute/documentation-contribution.md)
- [Writing Instructions](contribute/writing-instructions.md)
- [Communication in Community](contribute/communication-in-community.md)
- [FAQs](contribute/FAQ.md)
\ No newline at end of file
......@@ -11,23 +11,20 @@ import account_appAccount from '@ohos.account.appAccount';
```
## 系统能力
SystemCapability.Account.AppAccount
## account_appAccount.createAppAccountManager
createAppAccountManager(): AppAccountManager;
createAppAccountManager(): AppAccountManager
应用帐号管理:获取应用帐号模块对象。
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| AppAccountManager | 获取应用帐号模块的实例。 |
**系统能力:** SystemCapability.Account.AppAccount
- 示例:
**返回值:**
| 类型 | 说明 |
| ----------------- | ------------------------ |
| AppAccountManager | 获取应用帐号模块的实例。 |
**示例:**
```
var appAccountManager = account.createAppAccountManager();
```
......@@ -38,20 +35,20 @@ createAppAccountManager(): AppAccountManager;
### addAccount
addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void;
addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
将此应用的帐号名添加到帐号管理服务中,使用callback回调异步返回结果。
需要权限:无。
**系统能力:** SystemCapability.Account.AppAccount
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | ------------------------------------------ |
| name | string | 是 | 要添加的应用帐户的名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 将此应用的帐号名添加到帐号管理服务的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------------------------------ |
| name | string | 是 | 要添加的应用帐户的名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 将此应用的帐号名添加到帐号管理服务的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -62,21 +59,21 @@ addAccount(name: string, callback: AsyncCallback&lt;void&gt;): void;
### addAccount
addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;): void;
addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;): void
将此应用程序的帐号名和额外信息添加到帐号管理服务中,使用callback回调异步返回结果。
需要权限:无。
**系统能力:** SystemCapability.Account.AppAccount
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 要添加的应用帐户的名称。 |
| extraInfo | string | 是 | 要添加的应用帐户的额外信息(例如token等),额外的信息不能是应用帐号的敏感信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 将此应用程序的帐号名和额外信息添加到帐号管理服务中的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 要添加的应用帐户的名称。 |
| extraInfo | string | 是 | 要添加的应用帐户的额外信息(例如token等),额外的信息不能是应用帐号的敏感信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 将此应用程序的帐号名和额外信息添加到帐号管理服务中的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -89,26 +86,26 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;)
### addAccount
addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;;
addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;
将此应用的帐号名或额外信息添加到帐号管理服务中,使用Promise方式异步返回结果。
需要权限:无。
**系统能力:** SystemCapability.Account.AppAccount
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------------------------------------------------------ |
| name | string | 是 | 要添加的应用帐户的名称。 |
| extraInfo | string | 是 | 要添加的应用帐户的额外信息,额外的信息不能是应用帐号的敏感信息。 |
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------------------------------------------------------ |
| name | string | 是 | 要添加的应用帐户的名称。 |
| extraInfo | string | 是 | 要添加的应用帐户的额外信息,额外的信息不能是应用帐号的敏感信息。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| ------------- | ---------------------------------- |
| Promise&lt;void&gt; | romise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| ------------------- | ---------------------------------- |
| Promise&lt;void&gt; | romise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -121,22 +118,22 @@ addAccount(name: string, extraInfo?: string): Promise&lt;void&gt;;
### addAccountImplicitly<sup>8+</sup>
addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
根据指定的帐号所有者、鉴权类型和可选项,隐式地添加应用帐号,并使用callback回调异步返回结果。
需要权限:无。
**系统能力:** SystemCapability.Account.AppAccount
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | --- | -------------------------- |
| owner | string | 是 | 要添加的应用帐户的所有者包名。 |
| authType | string | 是 | 要添加的应用帐户的鉴权类型。 |
| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------ |
| owner | string | 是 | 要添加的应用帐户的所有者包名。 |
| authType | string | 是 | 要添加的应用帐户的鉴权类型。 |
| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
- 示例:
**示例:**
```
import featureAbility from '@ohos.ability.featureAbility';
......@@ -162,18 +159,20 @@ addAccountImplicitly(owner: string, authType: string, options: {[key: string]: a
### deleteAccount
deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void;
deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void
从帐号管理服务中删除应用帐号,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | ---------------------------------- |
| name | string | 是 | 要删除的应用帐户的名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 帐号管理服务中删除应用帐号的回调。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------------------- |
| name | string | 是 | 要删除的应用帐户的名称。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 帐号管理服务中删除应用帐号的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -184,23 +183,25 @@ deleteAccount(name: string, callback: AsyncCallback&lt;void&gt;): void;
### deleteAccount
deleteAccount(name: string): Promise&lt;void&gt;;
deleteAccount(name: string): Promise&lt;void&gt;
从帐号管理服务中删除应用帐号,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------ |
| name | string | 是 | 要删除的应用帐户的名称。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------------ |
| name | string | 是 | 要删除的应用帐户的名称。 |
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -213,19 +214,21 @@ deleteAccount(name: string): Promise&lt;void&gt;;
### disableAppAccess
disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void;
disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
禁止指定第三方应用帐户的名称访问指定包名称的第三方应用,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 要禁用访问的第三方应用帐户的名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 要禁用访问的第三方应用帐户的名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -236,24 +239,26 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;vo
### disableAppAccess
disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;;
disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
禁止指定第三方应用帐户的名称访问指定包名称的第三方应用,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---------------------------------- |
| name | string | 是 | 要禁用访问的第三方应用帐户的名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---------------------------------- |
| name | string | 是 | 要禁用访问的第三方应用帐户的名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**返回值:**
- 示例:
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -266,19 +271,21 @@ disableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;;
### enableAppAccess
enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void;
enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;void&gt;): void
允许指定第三方应用帐户的名称访问指定包名称的第三方应用,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 应用帐号名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 允许指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------------------------------------------------------ |
| name | string | 是 | 应用帐号名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 允许指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -289,24 +296,26 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback&lt;voi
### enableAppAccess
enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;;
enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;
允许指定第三方应用帐户的名称访问指定包名称的第三方应用,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------------ |
| name | string | 是 | 应用帐号名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------------ |
| name | string | 是 | 应用帐号名称。 |
| bundleName | string | 是 | 第三方应用的包名。 |
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**返回值:**
- 示例:
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
```
app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => {
......@@ -318,20 +327,22 @@ enableAppAccess(name: string, bundleName: string): Promise&lt;void&gt;;
### checkAppAccountSyncEnable
checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;): void;
checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;): void
检查指定应用帐号是否允许应用数据同步,使用callback回调异步返回结果。
需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。
**系统能力:** SystemCapability.Account.AppAccount
- 参数:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | -------------------------------------------- |
| name | string | 是 | 应用帐号名称。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 检查指定应用帐号是否允许应用数据同步的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------------------------------------- |
| name | string | 是 | 应用帐号名称。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 检查指定应用帐号是否允许应用数据同步的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -343,25 +354,27 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback&lt;boolean&gt;):
### checkAppAccountSyncEnable
checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;;
checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;
检查指定应用帐号是否允许应用数据同步,使用Promise方式异步返回结果。
需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------- |
| name | string | 是 | 应用帐号名称。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------- |
| name | string | 是 | 应用帐号名称。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :--------------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -374,20 +387,22 @@ checkAppAccountSyncEnable(name: string): Promise&lt;boolean&gt;;
### setAccountCredential
setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback&lt;void&gt;): void;
setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback&lt;void&gt;): void
设置此应用程序帐号的凭据,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------------------- | ---- | ---------------------------- |
| name | string | 是 | 应用程序帐户的名称。 |
| credentialType | string | 是 | 要设置的凭据的类型。 |
| credential | string | 是 | 要设置的凭据。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置此应用帐号的凭据的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------------------------- | ---- | ---------------------------- |
| name | string | 是 | 应用程序帐户的名称。 |
| credentialType | string | 是 | 要设置的凭据的类型。 |
| credential | string | 是 | 要设置的凭据。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置此应用帐号的凭据的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -398,25 +413,27 @@ setAccountCredential(name: string, credentialType: string, credential: string,ca
### setAccountCredential
setAccountCredential(name: string, credentialType: string, credential: string): Promise&lt;void&gt;;
setAccountCredential(name: string, credentialType: string, credential: string): Promise&lt;void&gt;
设置此应用程序帐号的凭据,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | -------------------- |
| name | string | 是 | 应用帐户的名称。 |
| credentialType | string | 是 | 要设置的凭据的类型。 |
| credential | string | 是 | 要设置的凭据。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | -------------------- |
| name | string | 是 | 应用帐户的名称。 |
| credentialType | string | 是 | 要设置的凭据的类型。 |
| credential | string | 是 | 要设置的凭据。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -429,19 +446,21 @@ setAccountCredential(name: string, credentialType: string, credential: string):
### setAccountExtraInfo
setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;): void;
setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt;void&gt;): void
设置此应用程序帐号的额外信息,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------- | ---- | -------------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| extraInfo | string | 是 | 要设置的额外信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置此应用帐号的额外信息的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------- | ---- | -------------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| extraInfo | string | 是 | 要设置的额外信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置此应用帐号的额外信息的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -452,24 +471,26 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback&lt;
### setAccountExtraInfo
setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt;;
setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt;
设置此应用程序帐号的额外信息,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------------ |
| name | string | 是 | 应用帐户的名称。 |
| extraInfo | string | 是 | 要设置的额外信息。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------------ |
| name | string | 是 | 应用帐户的名称。 |
| extraInfo | string | 是 | 要设置的额外信息。 |
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -482,21 +503,23 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise&lt;void&gt;;
### setAppAccountSyncEnable
setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void;
setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback&lt;void&gt;): void
设置指定的应用程序帐号是否允许应用程序数据同步,使用callback回调异步返回结果。
需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | -------------------------------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| isEnable | boolean | 是 | 是否允许应用数据同步。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置指定的应用帐号是否允许应用程序数据同步的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------------------------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| isEnable | boolean | 是 | 是否允许应用数据同步。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置指定的应用帐号是否允许应用程序数据同步的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -507,26 +530,28 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback
### setAppAccountSyncEnable
setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;;
setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;
设置指定的应用程序帐号是否允许应用程序数据同步,使用Promise方式异步返回结果。
需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------- | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| isEnable | boolean | 是 | 是否允许应用数据同步。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------- | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| isEnable | boolean | 是 | 是否允许应用数据同步。 |
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**返回值:**
- 示例:
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -539,20 +564,22 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise&lt;void&gt;;
### setAssociatedData
setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback&lt;void&gt;): void;
setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback&lt;void&gt;): void
设置与此应用程序帐号关联的数据,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | ---------------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| key | string | 是 | 要设置的数据的键,密钥可以自定义。 |
| value | string | 是 | 要设置的数据的值。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置与此应用帐号关联的数据的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| key | string | 是 | 要设置的数据的键,密钥可以自定义。 |
| value | string | 是 | 要设置的数据的值。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置与此应用帐号关联的数据的回调。 |
**示例:**
```
app_account_instance.setAssociatedData("ZhangSan", "k001", "v001", (err) => {
......@@ -562,25 +589,27 @@ setAssociatedData(name: string, key: string, value: string, callback: AsyncCallb
### setAssociatedData
setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;;
setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;
设置与此应用程序帐号关联的数据,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| key | string | 是 | 要设置的数据的键,密钥可以自定义。 |
| value | string | 是 | 要设置的数据的值。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| key | string | 是 | 要设置的数据的键,密钥可以自定义。 |
| value | string | 是 | 要设置的数据的值。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -593,19 +622,21 @@ setAssociatedData(name: string, key: string, value: string): Promise&lt;void&gt;
### getAccountCredential
getAccountCredential(name: string, credentialType: string, callback: AsyncCallback&lt;string&gt;): void;
getAccountCredential(name: string, credentialType: string, callback: AsyncCallback&lt;string&gt;): void
获取此应用帐号的凭据,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | --------------------- | ---- | ---------------------------- |
| name | string | 是 | 应用帐号名称。 |
| credentialType | string | 是 | 要获取的凭据的类型。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取此应用帐号的凭据的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | --------------------------- | ---- | ---------------------------- |
| name | string | 是 | 应用帐号名称。 |
| credentialType | string | 是 | 要获取的凭据的类型。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取此应用帐号的凭据的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -617,24 +648,26 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba
### getAccountCredential
getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt;;
getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt;
获取此应用程序帐号的凭据,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | -------------------- |
| name | string | 是 | 应用帐号名称。 |
| credentialType | string | 是 | 要获取的凭据的类型。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------------- | ------ | ---- | -------------------- |
| name | string | 是 | 应用帐号名称。 |
| credentialType | string | 是 | 要获取的凭据的类型。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :-------------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -647,18 +680,20 @@ getAccountCredential(name: string, credentialType: string): Promise&lt;string&gt
### getAccountExtraInfo
getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void;
getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void
获取此应用帐号的额外信息,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | -------------------------------- |
| name | string | 是 | 应用帐号名称。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取此应用帐号的额外信息的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | -------------------------------- |
| name | string | 是 | 应用帐号名称。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取此应用帐号的额外信息的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -670,23 +705,25 @@ getAccountExtraInfo(name: string, callback: AsyncCallback&lt;string&gt;): void;
### getAccountExtraInfo
getAccountExtraInfo(name: string): Promise&lt;string&gt;;
getAccountExtraInfo(name: string): Promise&lt;string&gt;
获取此应用程序帐号的额外信息,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------- |
| name | string | 是 | 应用帐号名称。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | -------------- |
| name | string | 是 | 应用帐号名称。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :-------------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -699,19 +736,21 @@ getAccountExtraInfo(name: string): Promise&lt;string&gt;;
### getAssociatedData
getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&gt;): void;
getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&gt;): void
获取与此应用程序帐号关联的数据,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------------- |
| name | string | 是 | 应用帐号名称。 |
| key | string | 是 | 要获取的数据的key。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取与此应用帐号关联的数据的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------------- |
| name | string | 是 | 应用帐号名称。 |
| key | string | 是 | 要获取的数据的key。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 获取与此应用帐号关联的数据的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -723,24 +762,26 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback&lt;string&g
### getAssociatedData
getAssociatedData(name: string, key: string): Promise&lt;string&gt;;
getAssociatedData(name: string, key: string): Promise&lt;string&gt;
获取与此应用程序帐号关联的数据,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------- |
| name | string | 是 | 应用帐号名称。 |
| key | string | 是 | 要获取的数据的key。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------------- |
| name | string | 是 | 应用帐号名称。 |
| key | string | 是 | 要获取的数据的key。 |
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
**返回值:**
- 示例:
| 类型 | 说明 |
| :-------------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -753,19 +794,21 @@ getAssociatedData(name: string, key: string): Promise&lt;string&gt;;
### getAllAccessibleAccounts
getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void;
getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void
获取全部应用已授权帐号信息。
需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。
**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ---------------- |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 应用帐号信息列表 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | ---------------- |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 应用帐号信息列表 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -777,19 +820,21 @@ getAllAccessibleAccounts(callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&
### getAllAccessibleAccounts
getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;;
getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
获取全部应用已授权帐号信息。
需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。
**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。
**系统能力:** SystemCapability.Account.AppAccount
- 参数:
**参数:**
| 类型 | 说明 |
| ------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| ------------------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -802,20 +847,22 @@ getAllAccessibleAccounts(): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;;
### getAllAccounts
getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void;
getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt;): void
获取指定应用全部帐号信息。
需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。
**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------ | ---- | ---------------- |
| owner | string | 是 | 应用包名称 |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 应用帐号信息列表 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | ---------------- |
| owner | string | 是 | 应用包名称 |
| callback | AsyncCallback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 应用帐号信息列表 |
- 示例:
**示例:**
```
const appAccountManager = account.createAppAccountManager();
......@@ -828,25 +875,27 @@ getAllAccounts(owner: string, callback: AsyncCallback&lt;Array&lt;AppAccountInfo
### getAllAccounts
getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;;
getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;
获取指定应用全部帐号信息。
需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。
**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------- |
| owner | string | 是 | 应用包名称 |
**参数:**
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------- |
| owner | string | 是 | 应用包名称 |
**参数:**
| 类型 | 说明 |
| ------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| ------------------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;AppAccountInfo&gt;&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -860,19 +909,21 @@ getAllAccounts(owner: string): Promise&lt;Array&lt;AppAccountInfo&gt;&gt;;
### on('change')
on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;AppAccountInfo&gt;&gt;): void;
on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;AppAccountInfo&gt;&gt;): void
订阅指定帐号所有者的帐户变更事件,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------- | ---- | ------------------------------------------------------------ |
| type | 'change' | 是 | 关于帐户更改事件,当帐户所有者更新帐户时,订阅者将收到通知。 |
| owners | Array&lt;string&gt; | 是 | 指示帐户的所有者。 |
| callback | Callback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 订阅指定帐号所有者的帐户变更事件的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ |
| type | 'change' | 是 | 关于帐户更改事件,当帐户所有者更新帐户时,订阅者将收到通知。 |
| owners | Array&lt;string&gt; | 是 | 指示帐户的所有者。 |
| callback | Callback&lt;Array&lt;AppAccountInfo&gt;&gt; | 是 | 订阅指定帐号所有者的帐户变更事件的回调。 |
**示例:**
```
const appAccountManager = account.createAppAccountManager();
......@@ -889,18 +940,20 @@ on(type: 'change', owners: Array&lt;string&gt;, callback: Callback&lt;Array&lt;A
### off('change')
off(type: 'change', callback?: Callback&lt;void&gt;): void;
off(type: 'change', callback?: Callback<Array\<AppAccountInfo>>): void
取消订阅帐号事件,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------- | ---- | ------------------------ |
| type | 'change' | 是 | 关于帐户更改事件。 |
| callback | Callback&lt;void&gt; | 否 | 取消订阅帐号事件的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------- | ---- | ------------------------ |
| type | 'change' | 是 | 关于帐户更改事件。 |
| callback | Callback<Array\<AppAccountInfo>> | 否 | 取消订阅帐号事件的回调。 |
**示例:**
```
const appAccountManager = account.createAppAccountManager();
......@@ -920,21 +973,23 @@ off(type: 'change', callback?: Callback&lt;void&gt;): void;
### authenticate<sup>8+</sup>
authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
鉴权应用帐户以获取OAuth令牌,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | --------------------------- |
| name | string | 是 | 要鉴权的应用帐户的名称。 |
| owner | string | 是 | 要鉴权的应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| options | {[key: string]: any} | 是 | 鉴权所需的可选项。 |
| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------ |
| name | string | 是 | 要鉴权的应用帐户的名称。 |
| owner | string | 是 | 要鉴权的应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| options | {[key: string]: any} | 是 | 鉴权所需的可选项。 |
| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
- 示例:
**示例:**
```
import featureAbility from '@ohos.ability.featureAbility';
......@@ -960,20 +1015,22 @@ authenticate(name: string, owner: string, authType: string, options: {[key: stri
### getOAuthToken<sup>8+</sup>
getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback&lt;string&gt;): void;
getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback&lt;string&gt;): void
获取指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | -------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 查询结果的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 查询结果的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -985,25 +1042,27 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall
### getOAuthToken<sup>8+</sup>
getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&gt;;
getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&gt;
获取指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | -------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
**参数:**
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
**参数:**
| 类型 | 说明 |
| --------------------- | -------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| --------------------- | ----------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1016,20 +1075,22 @@ getOAuthToken(name: string, owner: string, authType: string): Promise&lt;string&
### setOAuthToken<sup>8+</sup>
setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback&lt;void&gt;): void;
setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback&lt;void&gt;): void
设置指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | OAuth令牌。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置结果的回调。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | OAuth令牌。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置结果的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1040,25 +1101,27 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall
### setOAuthToken<sup>8+</sup>
setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt;;
setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt;
设置指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | OAuth令牌。 |
**参数:**
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | OAuth令牌。 |
| 类型 | 说明 |
| ------------------- | -------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**参数:**
- 示例:
| 类型 | 说明 |
| ------------------- | ----------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1071,21 +1134,23 @@ setOAuthToken(name: string, authType: string, token: string): Promise&lt;void&gt
### deleteOAuthToken<sup>8+</sup>
deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback&lt;void&gt;): void;
deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback&lt;void&gt;): void
删除指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------------ |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | 要删除的OAuth令牌。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 删除结果的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | 要删除的OAuth令牌。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 删除结果的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1096,26 +1161,28 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c
### deleteOAuthToken<sup>8+</sup>
deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise&lt;void&gt;;
deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise&lt;void&gt;
删除指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------ |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | 要删除的OAuth令牌。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| authType | string | 是 | 鉴权类型。 |
| token | string | 是 | 要删除的OAuth令牌。 |
- 参数:
**参数:**
| 类型 | 说明 |
| ------------------------------ | --------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| ------------------- | ----------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1128,21 +1195,23 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string):
### setOAuthTokenVisibility<sup>8+</sup>
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback&lt;void&gt;): void;
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback&lt;void&gt;): void
设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 被设置可见性的应用包名。|
| isVisible | boolean | 是 | 是否可见。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置结果的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------------------ |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 被设置可见性的应用包名。 |
| isVisible | boolean | 是 | 是否可见。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 设置结果的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1153,26 +1222,28 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
### setOAuthTokenVisibility<sup>8+</sup>
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise&lt;void&gt;;
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise&lt;void&gt;
设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ------------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 被设置可见性的应用包名。|
| isVisible | boolean | 是 | 是否可见。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------- | ---- | ------------------------ |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 被设置可见性的应用包名。 |
| isVisible | boolean | 是 | 是否可见。 |
- 参数:
**参数:**
| 类型 | 说明 |
| ------------------------------ | --------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| ------------------- | ----------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1186,20 +1257,22 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi
### checkOAuthTokenVisibility<sup>8+</sup>
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void;
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback&lt;boolean&gt;): void
检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------- | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 用于检查可见性的应用包名。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 检查结果的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------- | ---- | -------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 用于检查可见性的应用包名。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 检查结果的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1211,25 +1284,27 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca
### checkOAuthTokenVisibility<sup>8+</sup>
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise&lt;boolean&gt;;
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise&lt;boolean&gt;
检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------------------------- | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 用于检查可见性的应用包名。 |
**参数:**
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | -------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 鉴权类型。 |
| bundleName | string | 是 | 用于检查可见性的应用包名。 |
| 类型 | 说明 |
| ------------------------------ | ------------------------ |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果。 |
**参数:**
- 示例:
| 类型 | 说明 |
| ---------------------- | ----------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1242,19 +1317,21 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P
### getAllOAuthTokens<sup>8+</sup>
getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array&lt;OAuthTokenInfo&gt;&gt;): void;
getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array&lt;OAuthTokenInfo&gt;&gt;): void
获取指定应用对调用方全部可见的OAuth令牌,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | ------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| callback | AsyncCallback&lt;Array&lt;OAuthTokenInfo&gt;&gt; | 是 | 查询结果的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------ | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| callback | AsyncCallback&lt;Array&lt;OAuthTokenInfo&gt;&gt; | 是 | 查询结果的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1266,24 +1343,26 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback&lt;Array&
### getAllOAuthTokens<sup>8+</sup>
getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenInfo&gt;&gt;;
getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenInfo&gt;&gt;
获取指定应用帐户对调用方可见的全部OAuth令牌,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
- 参数:
**参数:**
| 类型 | 说明 |
| ------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;OAuthTokenInfo&gt;&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| ------------------------------------------ | ----------------------------------- |
| Promise&lt;Array&lt;OAuthTokenInfo&gt;&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1296,19 +1375,21 @@ getAllOAuthTokens(name: string, owner: string): Promise&lt;Array&lt;OAuthTokenIn
### getOAuthList<sup>8+</sup>
getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void;
getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------ |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 查询结果的回调。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 查询结果的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1320,24 +1401,26 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback&lt;Array&lt
### getOAuthList<sup>8+</sup>
getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt;;
getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt;
获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | ------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
**参数:**
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------- |
| name | string | 是 | 应用帐户的名称。 |
| owner | string | 是 | 应用帐户的所有者包名。 |
| 类型 | 说明 |
| ------------------------------ | ------------------------------------ |
| Promise&lt;Array&lt;string&gt;&gt; | Promise实例,用于获取异步返回结果。 |
**参数:**
- 示例:
| 类型 | 说明 |
| ---------------------------------- | ----------------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1350,18 +1433,20 @@ getOAuthList(name: string, authType: string): Promise&lt;Array&lt;string&gt;&gt;
### getAuthenticatorCallback<sup>8+</sup>
getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;AuthenticatorCallback&gt;): void;
getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;AuthenticatorCallback&gt;): void
获取鉴权会话的认证器回调,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------------------ | ---- | -------------- |
| sessionId | string | 是 | 鉴权会话的标识。 |
| callback | AsyncCallback&lt;AuthenticatorCallback&gt; | 是 | 查询结果的回调。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------------------ | ---- | ---------------- |
| sessionId | string | 是 | 鉴权会话的标识。 |
| callback | AsyncCallback&lt;AuthenticatorCallback&gt; | 是 | 查询结果的回调。 |
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1383,23 +1468,25 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback&lt;Authentic
### getAuthenticatorCallback<sup>8+</sup>
getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt;;
getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt;
获取鉴权会话的认证器回调,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | -------------- |
| sessionId | string | 是 | 鉴权会话的标识。 |
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ---------------- |
| sessionId | string | 是 | 鉴权会话的标识。 |
- 参数:
**参数:**
| 类型 | 说明 |
| ------------------------------------ | -------------------------------- |
| Promise&lt;AuthenticatorCallback&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| ------------------------------------ | ----------------------------------- |
| Promise&lt;AuthenticatorCallback&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1421,18 +1508,20 @@ getAuthenticatorCallback(sessionId: string): Promise&lt;AuthenticatorCallback&gt
### getAuthenticatorInfo<sup>8+</sup>
getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo&gt;): void;
getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo&gt;): void
获取指定应用帐户的认证器信息,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ------------------- |
| owner | string | 是 | 应用帐户的所有者包名。 |
| callback | AsyncCallback&lt;AuthenticatorInfo&gt; | 是 | 查询结果的回调。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------------------- | ---- | ---------------------- |
| owner | string | 是 | 应用帐户的所有者包名。 |
| callback | AsyncCallback&lt;AuthenticatorInfo&gt; | 是 | 查询结果的回调。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1444,23 +1533,25 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback&lt;AuthenticatorInfo
### getAuthenticatorInfo<sup>8+</sup>
getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;;
getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;
获取指定应用帐户的认证器信息,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | -------------------- |
| owner | string | 是 | 应用帐户的所有者包名。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ---------------------- |
| owner | string | 是 | 应用帐户的所有者包名。 |
- 参数:
**参数:**
| 类型 | 说明 |
| ------------------------------ | ----------------------------------- |
| Promise&lt;AuthenticatorInfo&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| -------------------------------- | ----------------------------------- |
| Promise&lt;AuthenticatorInfo&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1475,8 +1566,10 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;;
表示应用帐号信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 参数名 | 类型 | 必填 | 说明 |
| ----- | ------ | ---- | ---------------- |
| ------ | ------ | ---- | ---------------------- |
| owner | string | 是 | 应用帐户的所有者包名。 |
| name | string | 是 | 应用帐户的名称。 |
......@@ -1484,8 +1577,10 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;;
表示OAuth令牌信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------ | ---- | -------------- |
| -------- | ------ | ---- | ---------------- |
| authType | string | 是 | 令牌的鉴权类型。 |
| token | string | 是 | 令牌的取值。 |
......@@ -1493,8 +1588,10 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;;
表示OAuth认证器信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------------ |
| ------- | ------ | ---- | -------------------- |
| owner | string | 是 | 认证器的所有者包名。 |
| iconId | string | 是 | 认证器的图标标识。 |
| labelId | string | 是 | 认证器的标签标识。 |
......@@ -1503,8 +1600,10 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;;
表示常量的枚举。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 名称 | 默认值 | 描述 |
| ----------------------------- | ---------------------- | ----------------------- |
| ----------------------------- | ---------------------- | ------------------------- |
| ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | 表示操作_隐式添加帐号。 |
| ACTION_AUTHENTICATE | "authenticate" | 表示操作_鉴权。 |
| KEY_NAME | "name" | 表示键名_应用帐户名称。 |
......@@ -1521,8 +1620,10 @@ getAuthenticatorInfo(owner: string): Promise&lt;AuthenticatorInfo&gt;;
表示返回码的枚举。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。
| 名称 | 默认值 | 描述 |
| ----------------------------------- | ----- | ---------------------- |
| ----------------------------------- | ------ | ------------------------ |
| SUCCESS | 0 | 表示操作成功。 |
| ERROR_ACCOUNT_NOT_EXIST | 10001 | 表示应用帐户不存在。 |
| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | 表示应用帐户服务异常。 |
......@@ -1549,17 +1650,19 @@ OAuth认证器回调接口。
### onResult<sup>8+</sup>
onResult: (code: number, result: {[key: string]: any}) =&gt; void;
onResult: (code: number, result: {[key: string]: any}) =&gt; void
通知鉴权结果。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------------- | ---- | ----------- |
| code | number | 是 | 鉴权结果码。 |
| result | {[key: string]: any} | 是 | 鉴权结果。 |
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------------- | ---- | ------------ |
| code | number | 是 | 鉴权结果码。 |
| result | {[key: string]: any} | 是 | 鉴权结果。 |
- 示例:
**示例:**
```
const appAccountManager = account_appAccount.createAppAccountManager();
......@@ -1577,16 +1680,18 @@ onResult: (code: number, result: {[key: string]: any}) =&gt; void;
### onRequestRedirected<sup>8+</sup>
onRequestRedirected: (request: Want) =&gt; void;
onRequestRedirected: (request: Want) =&gt; void
通知鉴权请求被跳转。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ---- | ---- | ------------------ |
| request | Want | 是 | 用于跳转的请求信息。 |
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ---- | ---- | -------------------- |
| request | Want | 是 | 用于跳转的请求信息。 |
- 示例:
**示例:**
```
class MyAuthenticator extends account_appAccount.Authenticator {
......@@ -1612,34 +1717,38 @@ OAuth认证器基类。
### addAccountImplicitly<sup>8+</sup>
addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
根据指定的鉴权类型和可选项,隐式地添加应用帐户,并使用callback回调异步返回结果。
- 参数:
| 参数名 | 类型 | 必填 | 说明 |
| ---------------- | --------------------- | --- | -------------------------- |
| authType | string | 是 | 应用帐户的鉴权类型。 |
| callerBundleName | string | 是 | 鉴权请求方的包名。 |
| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------------- | --------------------- | ---- | ------------------------------ |
| authType | string | 是 | 应用帐户的鉴权类型。 |
| callerBundleName | string | 是 | 鉴权请求方的包名。 |
| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
### authenticate<sup>8+</sup>
authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void;
authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void
对应用帐户进行鉴权,获取OAuth令牌,并使用callback回调异步返回结果。
- 参数:
| 接口名 | 类型 | 必填 | 说明 |
| ---------------- | --------------------- | ---- | -------------------------- |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 应用帐户的鉴权类型。 |
| callerBundleName | string | 是 | 鉴权请求方的包名。 |
| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
**系统能力:** SystemCapability.Account.AppAccount
**参数:**
| 接口名 | 类型 | 必填 | 说明 |
| ---------------- | --------------------- | ---- | ------------------------------ |
| name | string | 是 | 应用帐户的名称。 |
| authType | string | 是 | 应用帐户的鉴权类型。 |
| callerBundleName | string | 是 | 鉴权请求方的包名。 |
| options | {[key: string]: any} | 是 | 鉴权所需要的可选项。 |
| callback | AuthenticatorCallback | 是 | 认证器回调,用于返回鉴权结果。 |
- 示例:
**示例:**
```
class MyAuthenticator extends account_appAccount.Authenticator {
......
......@@ -461,7 +461,7 @@ queryMyCard(attrs?: ContactAttributes): Promise&lt;Contact&gt;
## contact.selectContact
selectContact(AsyncCallback&lt;Array&lt;Contact&gt;&gt;): void
selectContact(callback: AsyncCallback&lt;Array&lt;Contact&gt;&gt;): void
选择联系人,使用callback方式作为异步方法。
......
# 输入监听
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> - 本模块接口均为系统接口,三方应用不支持调用。
## 导入模块
```
import inputMonitor from '@ohos.multimodalInput.inputMonitor';
```
## 权限
ohos.permission.INPUT_MONITORING
## inputMonitor.on
on(type: "touch", receiver: TouchEventReceiver): void
开始监听全局输入。
**需要权限:**ohos.permission.INPUT_MONITORING
**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听输入事件类型,只支持“touch”。 |
| receiver | [TouchEventReceiver](#toucheventreceiver) | 是 | 触摸输入事件回调函数。 |
**示例:**
```
callback: function (value) {
if (checkEvent(value)) {
//事件满足业务要求,事件被消费
return true;
} else {
//事件不满足业务要求,事件未被消费
return false;
}
},
testOn: function () {
console.info("InputMonitorJsTest---start---testOn");
inputMonitor.on(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOn");
}
```
## inputMonitor.off
off(type: "touch", receiver: TouchEventReceiver): void
停止监听全局输入。
**需要权限:**ohos.permission.INPUT_MONITORING
**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| type | string | 是 | 监听输入事件类型,只支持“touch”。 |
| receiver | [TouchEventReceiver](#toucheventreceiver) | 否 | 触摸输入事件回调函数。 |
**示例:**
```
callback: function (value) {
if (checkEvent(value)) {
//事件满足业务要求,事件被消费
return true;
} else {
//事件不满足业务要求,事件未被消费
return false;
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
```
## TouchEventReceiver
触摸输入事件的回调函数,如果返回true,则触摸输入将被监听器消耗(系统执行关闭动作)。
### (touchEvent: TouchEvent): Boolean
触摸输入事件的回调函数。函数名由使用者定义,这里是函数调用时必须符合的格式,传入参数必须为TouchEvent类型,返回值为Boolean类型。
**系统能力:**SystemCapability.MultimodalInput.Input.InputMonitor
**参数:**
| 参数 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| touchEvent | [TouchEvent](../arkui-js/js-components-common-events.md) | 是 | 触摸输入事件回调函数,返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 |
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| Boolean | 返回true表示输触事件被监听器消费,false表示输触事件未被监听器消费。 |
**示例:**
```
callback: function (value) { //此处为(touchEvent:TouchEvent): Boolean 方法的实现
if (checkEvent(value)) {
//事件满足业务要求,事件被消费
return true;
} else {
//事件不满足业务要求,事件未被消费
return false;
}
},
testOff: function () {
console.info("InputMonitorJsTest---start---testOff");
inputMonitor.off(
"touch",
this.callback
);
console.info("InputMonitorJsTest---end---testOff");
}
```
......@@ -10,33 +10,34 @@
import account_osAccount from '@ohos.account.osAccount';
```
## 系统能力
SystemCapability.Account.OsAccount
## account_osAccount.getAccountManager
getAccountManager(): AccountManager
获取系统帐号能力的实例。
- 返回值:
| 类型 | 说明 |
| -------- | -------- |
| [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 |
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| --------------------------------- | ------------------------ |
| [AccountManager](#accountmanager) | 获取系统帐号能力的实例。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
```
## OsAccountType
枚举,系统帐号类型。
| 参数 | 默认值 | 说明 |
| -------- | -------- | -------- |
| ADMIN | 0 | 管理员帐号。|
| NORMAL | 1 | 普通帐号。|
| GUEST | 2 | 访客帐号。|
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。
| 参数 | 默认值 | 说明 |
| ------ | ------ | ------------ |
| ADMIN | 0 | 管理员帐号。 |
| NORMAL | 1 | 普通帐号。 |
| GUEST | 2 | 访客帐号。 |
## AccountManager
......@@ -48,14 +49,18 @@ activateOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
激活指定系统帐号,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | -------------------- |
| localId | number | 是 | 要激活的系统帐号ID。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**参数:**
- 示例:激活ID为100的系统帐号
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------------- |
| localId | number | 是 | 要激活的系统帐号ID。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**示例:**激活ID为100的系统帐号
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
......@@ -70,19 +75,23 @@ activateOsAccount(localId: number): Promise&lt;void&gt;
激活指定系统帐号,使用Promise方式异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 要激活的系统帐号ID。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | -------------------- |
| localId | number | 是 | 要激活的系统帐号ID。 |
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:激活ID为100的系统帐号
**示例:**激活ID为100的系统帐号
```
const accountManager = account_osAccount.getAccountManager();
var localId = 100;
......@@ -99,13 +108,15 @@ isMultiOsAccountEnable(callback: AsyncCallback&lt;boolean&gt;): void
判断是否支持多系统帐号,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | --------------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -121,13 +132,15 @@ isMultiOsAccountEnable(): Promise&lt;boolean&gt;
判断是否支持多系统帐号,使用Promise方式异步返回结果。
- 返回值:
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 |
| 类型 | 说明 |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -144,14 +157,18 @@ isOsAccountActived(localId: number, callback: AsyncCallback&lt;boolean&gt;): voi
判断指定系统帐号是否处于激活状态,使用callback回调异步返回结果。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------------------ |
| localId | number | 是 | 系统帐号ID。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,处于激活状态则返回true,否则返回false。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ------------------------------------------------- |
| localId | number | 是 | 系统帐号ID。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,处于激活状态则返回true,否则返回false。 |
- 示例:判断ID为100的系统帐号是否处于激活状态
**示例:**判断ID为100的系统帐号是否处于激活状态
```
const accountManager = account_osAccount.getAccountManager();
......@@ -168,19 +185,23 @@ isOsAccountActived(localId: number): Promise&lt;boolean&gt;
判断指定系统帐号是否处于激活状态,使用Promise方式异步返回结果。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
**系统能力:** SystemCapability.Account.OsAccount
- 返回值:
**参数:**
| 类型 | 说明 |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
**返回值:**
- 示例:判断ID为100的系统帐号是否处于激活状态
| 类型 | 说明 |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 |
**示例:**判断ID为100的系统帐号是否处于激活状态
```
const accountManager = account_osAccount.getAccountManager();
......@@ -196,17 +217,21 @@ isOsAccountActived(localId: number): Promise&lt;boolean&gt;
isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback&lt;boolean&gt;): void
判断指定系统帐号是否具有指定[约束](#系统帐号约束列表),使用callback回调异步返回结果。
判断指定系统帐号是否具有指定约束,使用callback回调异步返回结果。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------- | ---- | ------------------------------ |
| localId | number | 是 | 指定的系统帐号ID。 |
| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,具有指定约束则返回true,否则返回false。 |
**参数:**
- 示例:判断ID为100的系统帐号是否有禁止使用wifi的[约束](#系统帐号约束列表)
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ---------------------------- | ---- | ------------------------------------------------- |
| localId | number | 是 | 指定的系统帐号ID。 |
| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,具有指定约束则返回true,否则返回false。 |
**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束
```
const accountManager = account_osAccount.getAccountManager();
......@@ -221,22 +246,26 @@ isOsAccountConstraintEnable(localId: number, constraint: string, callback: Async
isOsAccountConstraintEnable(localId: number, constraint: string): Promise&lt;boolean&gt;
判断指定系统帐号是否具有指定[约束](#系统帐号约束列表),使用Promise方式异步返回结果。
判断指定系统帐号是否具有指定约束,使用Promise方式异步返回结果。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ---------------- |
| localId | number | 是 | 指定的系统帐号ID。 |
| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | ------ | ---- | ------------------------------------- |
| localId | number | 是 | 指定的系统帐号ID。 |
| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 |
**返回值:**
| 类型 | 说明 |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,具有指定[约束](#系统帐号约束列表)则返回true,否则返回false。 |
| 类型 | 说明 |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,具有指定约束则返回true,否则返回false。 |
- 示例:判断ID为100的系统帐号是否有禁止使用wifi的[约束](#系统帐号约束列表)
**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束
```
const accountManager = account_osAccount.getAccountManager();
......@@ -254,13 +283,15 @@ isTestOsAccount(callback: AsyncCallback&lt;boolean&gt;): void
检查当前系统帐号是否为测试帐号,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,是测试帐号则返回true,否则返回false。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ----------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,是测试帐号则返回true,否则返回false。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -276,13 +307,15 @@ isTestOsAccount(): Promise&lt;boolean&gt;
检查当前系统帐号是否为测试帐号,使用Promise方式异步返回结果。
- 返回值:
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 |
| 类型 | 说明 |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -299,13 +332,15 @@ isOsAccountVerified(callback: AsyncCallback&lt;boolean&gt;): void
检查当前系统帐号是否已验证,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,已验证则返回true,否则返回false。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ------------------------------------------- |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,已验证则返回true,否则返回false。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -321,14 +356,16 @@ isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): vo
检查指定系统帐号是否已验证,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------- | ---- | ---------------------------------- |
| localId | number | 否 | 指定的系统帐号ID。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,已验证则返回true,否则返回false。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ------------------------------------------- |
| localId | number | 否 | 指定的系统帐号ID。 |
| callback | AsyncCallback&lt;boolean&gt; | 是 | 回调结果,已验证则返回true,否则返回false。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -340,23 +377,25 @@ isOsAccountVerified(localId: number, callback: AsyncCallback&lt;boolean&gt;): vo
### isOsAccountVerified
isOsAccountVerified(localId: number?): Promise&lt;boolean&gt;
isOsAccountVerified(localId?: number): Promise&lt;boolean&gt;
检查指定系统帐号是否已验证,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 否 | 指定的系统帐号ID。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------------ |
| localId | number | 否 | 指定的系统帐号ID。 |
**返回值:**
| 类型 | 说明 |
| :--------------- | :---------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 |
| 类型 | 说明 |
| :--------------------- | :----------------------------------------------------------- |
| Promise&lt;boolean&gt; | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -373,14 +412,20 @@ removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
删除指定系统帐号,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | ------------------------ |
| localId | number | 是 | 要删除的系统帐号ID。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | -------------------- |
| localId | number | 是 | 要删除的系统帐号ID。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -399,19 +444,25 @@ removeOsAccount(localId: number): Promise&lt;void&gt;
删除指定系统帐号,使用Promise方式异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 要删除的系统帐号ID。 |
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
- 返回值:
**系统能力:** SystemCapability.Account.OsAccount
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | -------------------- |
| localId | number | 是 | 要删除的系统帐号ID。 |
**返回值:**
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -431,18 +482,24 @@ removeOsAccount(localId: number): Promise&lt;void&gt;
setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean,callback: AsyncCallback&lt;void&gt;): void
为指定系统帐号设置/删除[约束](#系统帐号约束列表),使用callback回调异步返回结果。
为指定系统帐号设置/删除约束返回结果。
此接口为系统接口,三方应用不支持调用。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------- | ---- | ------------------------------- |
| localId | number | 是 | 系统帐号ID。 |
| constraints | Array&lt;string&gt; | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 |
| enable | boolean | 是 | 设置(true)/删除(false) |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**系统能力:** SystemCapability.Account.OsAccount
- 示例:给ID为100的系统帐号设置禁止使用wifi的[约束](#系统帐号约束列表)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------------- | ---- | -------------------------------------------- |
| localId | number | 是 | 系统帐号ID。 |
| constraints | Array&lt;string&gt; | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 |
| enable | boolean | 是 | 设置(true)/删除(false) |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**示例:**给ID为100的系统帐号设置禁止使用wifi的约束
```
const accountManager = account_osAccount.getAccountManager();
......@@ -456,23 +513,29 @@ setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enabl
setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean): Promise&lt;void&gt;
为指定系统帐号设置/删除[约束](#系统帐号约束列表),使用Promise方式异步返回结果。
为指定系统帐号设置/删除约束回结果。
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------- | ---- | ----------------------- |
| localId | number | 是 | 系统帐号ID。 |
| constraints | Array&lt;string&gt; | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 |
| enable | boolean | 是 | 设置(true)/删除(false)。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | ------------------- | ---- | -------------------------------------------- |
| localId | number | 是 | 系统帐号ID。 |
| constraints | Array&lt;string&gt; | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 |
| enable | boolean | 是 | 设置(true)/删除(false)。 |
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:删除ID为100的系统帐号的禁止使用wifi的[约束](#系统帐号约束列表)
**示例:**删除ID为100的系统帐号的禁止使用wifi的约束
```
const accountManager = account_osAccount.getAccountManager();
......@@ -490,15 +553,19 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;
设置指定系统帐号的帐号名,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
| 参数名 | 类型 | 必填 | 说明 |
| :-------- | ------------------- | ---- | ------------------------ |
| localId | number | 是 | 系统帐号ID。 |
| localName | string | 是 | 帐号名。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**系统能力:** SystemCapability.Account.OsAccount
- 示例:将ID为100的系统帐号的帐号名设置成demoName
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| :-------- | ------------------------- | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
| localName | string | 是 | 帐号名。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**示例:**将ID为100的系统帐号的帐号名设置成demoName
```
const accountManager = account_osAccount.getAccountManager();
......@@ -515,20 +582,24 @@ setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;
设置指定系统帐号的帐号名,使用Promise方式异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ----------------------- |
| localId | number | 是 | 系统帐号ID。 |
| localName | string | 是 | 帐号名。 |
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
| localName | string | 是 | 帐号名。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:将ID为100的系统帐号的帐号名设置成demoName
**示例:**将ID为100的系统帐号的帐号名设置成demoName
```
const accountManager = account_osAccount.getAccountManager();
......@@ -547,13 +618,17 @@ getCreatedOsAccountsCount(callback: AsyncCallback&lt;number&gt;): void
获取已创建的系统帐号数量,使用callback回调异步返回结果。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------ |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是已创建的系统帐号的数量。 |
**系统能力:** SystemCapability.Account.OsAccount
- 示例:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------ |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是已创建的系统帐号的数量。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -569,13 +644,17 @@ getCreatedOsAccountsCount(): Promise&lt;number&gt;
获取已创建的系统帐号数量,使用Promise方式异步返回结果。
- 返回值:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 |
**返回值:**
- 示例:
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -592,13 +671,15 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback&lt;number&gt;): void
获取当前进程所属的系统帐号的帐号ID,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ----------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | -------------------------------------------------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -614,13 +695,15 @@ getOsAccountLocalIdFromProcess(): Promise&lt;number&gt;
获取当前进程所属的系统帐号的帐号ID,使用Promise方式异步返回结果。
- 返回值:
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 |
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -637,14 +720,16 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback&lt;number&gt;):
从进程uid中获取该uid所属的系统帐号的帐号ID,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | --------------------------------------- |
| uid | number | 是 | 进程uid。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | --------------------------------------------- |
| uid | number | 是 | 进程uid。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 |
- 示例:查询值为12345678的uid所属的系统帐号的帐号ID
**示例:**查询值为12345678的uid所属的系统帐号的帐号ID
```
const accountManager = account_osAccount.getAccountManager();
......@@ -661,19 +746,21 @@ getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;
从进程uid中获取该uid所属的系统帐号的帐号ID,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------- |
| uid | number | 是 | 进程uid。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | --------- |
| uid | number | 是 | 进程uid。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 |
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 |
- 示例:查询值为12345678的uid所属的系统帐号的帐号ID
**示例:**查询值为12345678的uid所属的系统帐号的帐号ID
```
const accountManager = account_osAccount.getAccountManager();
......@@ -685,20 +772,24 @@ getOsAccountLocalIdFromUid(uid: number): Promise&lt;number&gt;
});
```
### getOsAccountLocalIdFromDomain
### getOsAccountLocalIdFromDomain<sup>8+</sup>
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;number&gt;): void
根据域帐号信息,获取与其关联的系统帐号的帐号ID。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | --------------------------------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 |
**系统能力:** SystemCapability.Account.OsAccount
- 示例:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | --------------------------------------- | ---- | -------------------------------------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 |
**示例:**
```
var domainInfo = {domain: "testDomain", accountName: "testAccountName"};
......@@ -709,25 +800,29 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall
});
```
### getOsAccountLocalIdFromDomain
### getOsAccountLocalIdFromDomain<sup>8+</sup>
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise&lt;number&gt;
根据域帐号信息,获取与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------------- |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 |
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | --------------------------------------- | ---- | ------------ |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 |
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -745,13 +840,17 @@ queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void
查询允许创建的系统帐号的最大数量,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------------- |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是允许创建的系统帐号的最大数量。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------------ |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是允许创建的系统帐号的最大数量。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -767,13 +866,17 @@ queryMaxOsAccountNumber(): Promise&lt;number&gt;
查询允许创建的系统帐号的最大数量,使用Promise方式异步返回结果。
- 返回值:
此接口为系统接口,三方应用不支持调用。
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是允许创建的系统帐号的最大数量。 |
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是允许创建的系统帐号的最大数量。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -788,16 +891,20 @@ queryMaxOsAccountNumber(): Promise&lt;number&gt;
getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;string&gt;&gt;): void
获取指定系统帐号的全部[约束](#系统帐号约束列表),使用callback回调异步返回结果。
获取指定系统帐号的全部约束,使用callback回调异步返回结果。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------------------------------- |
| localId | number | 是 | 系统帐号ID。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 |
**系统能力:** SystemCapability.Account.OsAccount
- 示例:获取ID为100的系统帐号的全部[约束](#系统帐号约束列表)
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ |
| localId | number | 是 | 系统帐号ID。 |
| callback | AsyncCallback&lt;Array&lt;string&gt;&gt; | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 |
**示例:**获取ID为100的系统帐号的全部约束
```
const accountManager = account_osAccount.getAccountManager();
......@@ -812,21 +919,25 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback&lt;Array&lt;
getOsAccountAllConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
获取指定系统帐号的全部[约束](#系统帐号约束列表),使用Promise方式异步返回结果。
获取指定系统帐号的全部约束,使用Promise方式异步返回结果。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
**系统能力:** SystemCapability.Account.OsAccount
- 返回值:
**参数:**
| 类型 | 说明 |
| :--------------------- | :---------------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
**返回值:**
| 类型 | 说明 |
| :--------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;string&gt;&gt; | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 |
- 示例:获取ID为100的系统帐号的全部[约束](#系统帐号约束列表)
**示例:**获取ID为100的系统帐号的全部约束
```
const accountManager = account_osAccount.getAccountManager();
......@@ -844,13 +955,17 @@ queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&
查询已创建的所有系统帐号的信息列表,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | 是 | 回调结果,返回的是已创建的所有系统帐号的信息列表。 |
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | 是 | 回调结果,返回的是已创建的所有系统帐号的信息列表。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -866,13 +981,17 @@ queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
查询已创建的所有系统帐号的信息列表,使用Promise方式异步返回结果。
- 返回值:
此接口为系统接口,三方应用不支持调用。
| 类型 | 说明 |
| :---------------------------- | :---------------------------------- |
| Promise&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Promise实例,用于获取异步返回结果,返回的是已创建的所有系统帐号的信息列表。 |
**系统能力:** SystemCapability.Account.OsAccount
- 示例:
**返回值:**
| 类型 | 说明 |
| :---------------------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;[OsAccountInfo](#osaccountinfo)&gt;&gt; | Promise实例,用于获取异步返回结果,返回的是已创建的所有系统帐号的信息列表。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -883,19 +1002,21 @@ queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
});
```
### queryActivatedOsAccountIds
### queryActivatedOsAccountIds<sup>8+</sup>
queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
查询当前处于激活状态的系统帐号的ID列表,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ----------------------------------- | ---- | -------------------------------- |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ |
| callback | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -908,19 +1029,21 @@ queryActivatedOsAccountIds(callback: AsyncCallback&lt;Array&lt;number&gt;&gt;):
});
```
### queryActivatedOsAccountIds
### queryActivatedOsAccountIds<sup>8+</sup>
queryActivatedOsAccountIds(): Promise&lt;Array&lt;number&gt;&gt;
查询当前处于激活状态的系统帐号的ID列表,使用Promise方式异步返回结果。
- 返回值:
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| :---------------------------- | :---------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 |
| 类型 | 说明 |
| :--------------------------------- | :----------------------------------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -937,15 +1060,21 @@ createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&
创建一个系统帐号,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| :-------- | ---------------------------- | ---- | -------------------- |
| localName | string | 是 | 创建的系统帐号的名称。 |
| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是 | 回调结果,返回的是新创建的系统帐号的信息。 |
**系统能力:** SystemCapability.Account.OsAccount
- 示例:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| :-------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
| localName | string | 是 | 创建的系统帐号的名称。 |
| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是 | 回调结果,返回的是新创建的系统帐号的信息。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -961,20 +1090,26 @@ createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInf
创建一个系统帐号,使用Promise方式异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------- | ---- | ---------------- |
| localName | string | 是 | 创建的系统帐号的名称。 |
| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
- 返回值:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------------------------- | ---- | ---------------------- |
| localName | string | 是 | 创建的系统帐号的名称。 |
| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
| 类型 | 说明 |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 |
**返回值:**
- 示例:
| 类型 | 说明 |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -985,21 +1120,27 @@ createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInf
});
```
### createOsAccountForDomain
### createOsAccountForDomain<sup>8+</sup>
createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
根据域帐号信息,创建一个系统帐号并将其与域帐号关联,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| :-------- | ---------------------------- | ---- | -------------------- |
| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是 | 回调结果,返回的是新创建的系统帐号的信息。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ |
| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是 | 回调结果,返回的是新创建的系统帐号的信息。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1010,26 +1151,32 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal
});
```
### createOsAccountForDomain
### createOsAccountForDomain<sup>8+</sup>
createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise&lt;OsAccountInfo&gt;
根据传入的域帐号信息,创建与其关联的系统帐号,使用Promise方式异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
| 参数名 | 类型 | 必填 | 说明 |
| --------- | ------------- | ---- | ---------------- |
| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 |
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
- 返回值:
**系统能力:** SystemCapability.Account.OsAccount
| 类型 | 说明 |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| ---------- | --------------------------------------- | ---- | ---------------------- |
| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 |
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 |
**返回值:**
| 类型 | 说明 |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1047,13 +1194,17 @@ queryCurrentOsAccount(callback: AsyncCallback&lt;OsAccountInfo&gt;): void
查询当前进程所属的系统帐号的信息,使用callback回调异步返回结果。
- 参数:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------------------- |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1069,13 +1220,17 @@ queryCurrentOsAccount(): Promise&lt;OsAccountInfo&gt;
查询当前进程所属的系统帐号的信息,使用Promise方式异步返回结果。
- 返回值:
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 |
| 类型 | 说明 |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1092,14 +1247,20 @@ queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;
查询指定系统帐号的信息,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------------------- |
| localId | number | 是 | 要查询的系统帐号的ID |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是 | 回调结果,返回的是查到的系统帐号的信息。 |
**参数:**
- 示例:查询ID为100的系统帐号信息
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------------- | ---- | ---------------------------------------- |
| localId | number | 是 | 要查询的系统帐号的ID |
| callback | AsyncCallback&lt;[OsAccountInfo](#osaccountinfo)&gt; | 是 | 回调结果,返回的是查到的系统帐号的信息。 |
**示例:**查询ID为100的系统帐号信息
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1116,19 +1277,25 @@ queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;
查询指定系统帐号的信息,使用Promise方式异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | -------------------------- |
| localId | number | 是 | 要查询的系统帐号的ID |
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | -------------------- |
| localId | number | 是 | 要查询的系统帐号的ID |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise实例,用于获取异步返回结果,返回的是查到的系统帐号的信息。 |
| 类型 | 说明 |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountInfo](#osaccountinfo)&gt; | Promise实例,用于获取异步返回结果,返回的是查到的系统帐号的信息。 |
- 示例:查询ID为100的系统帐号信息
**示例:**查询ID为100的系统帐号信息
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1146,13 +1313,15 @@ getOsAccountTypeFromProcess(callback: AsyncCallback&lt;OsAccountType&gt;): void
查询当前进程所属的系统帐号的帐号类型,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------- | ---- | ---------------------------------------- |
| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 |
**参数:**
- 示例:
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- |
| callback | AsyncCallback&lt;[OsAccountType](#osaccounttype)&gt; | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1168,13 +1337,15 @@ getOsAccountTypeFromProcess(): Promise&lt;OsAccountType&gt;
查询当前进程所属的系统帐号的帐号类型,使用Promise方式异步返回结果。
- 返回值:
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| :--------------------- | :---------------------------------- |
| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 |
| 类型 | 说明 |
| :--------------------------------------------- | :----------------------------------------------------------- |
| Promise&lt;[OsAccountType](#osaccounttype)&gt; | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1191,13 +1362,17 @@ getDistributedVirtualDeviceId(callback: AsyncCallback&lt;string&gt;): void
获取分布式虚拟设备ID,使用callback回调异步返回结果。
- 参数:
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ---------------------------- |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调结果,返回的是分布式虚拟设备ID。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------ |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调结果,返回的是分布式虚拟设备ID。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1213,13 +1388,17 @@ getDistributedVirtualDeviceId(): Promise&lt;string&gt;
获取分布式虚拟设备ID,使用Promise方式异步返回结果。
- 返回值:
**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC
**系统能力:** SystemCapability.Account.OsAccount
**返回值:**
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 |
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 |
- 示例:
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1236,14 +1415,20 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;)
获取指定系统帐号的头像信息,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------ |
| localId | number | 是 | 系统帐号ID。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调结果,返回的是该系统帐号的头像信息。 |
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ---------------------------------------- |
| localId | number | 是 | 系统帐号ID。 |
| callback | AsyncCallback&lt;string&gt; | 是 | 回调结果,返回的是该系统帐号的头像信息。 |
- 示例:获取ID为100的系统帐号的头像
**示例:**获取ID为100的系统帐号的头像
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1260,19 +1445,25 @@ getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;
获取指定系统帐号的头像信息,使用Promise方式异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
**系统能力:** SystemCapability.Account.OsAccount
- 返回值:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果,返回的是该系统帐号的头像信息。 |
**返回值:**
- 示例:获取ID为100的系统帐号的头像
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;string&gt; | Promise实例,用于获取异步返回结果,返回的是该系统帐号的头像信息。 |
**示例:**获取ID为100的系统帐号的头像
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1290,15 +1481,21 @@ setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback
为指定系统帐号设置头像信息,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------- | ---- | ------------------------ |
| localId | number | 是 | 系统帐号ID。 |
| photo | string | 是 | 头像信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | ------------------------- | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
| photo | string | 是 | 头像信息。 |
| callback | AsyncCallback&lt;void&gt; | 是 | 回调结果。 |
- 示例:给ID为100的系统帐号设置头像
**示例:**给ID为100的系统帐号设置头像
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1318,20 +1515,26 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
为指定系统帐号设置头像信息,使用Promise方式异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
| photo | string | 是 | 头像信息。 |
**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
| photo | string | 是 | 头像信息。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
| 类型 | 说明 |
| :------------------ | :---------------------------------- |
| Promise&lt;void&gt; | Promise实例,用于获取异步返回结果。 |
- 示例:给ID为100的系统帐号设置头像
**示例:**给ID为100的系统帐号设置头像
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1347,20 +1550,22 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
});
```
### getOsAccountLocalIdBySerialNumber
### getOsAccountLocalIdBySerialNumber<sup>8+</sup>
getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&lt;number&gt;): void
通过SN码查询与其关联的系统帐号的帐号ID,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | --------------------- | ---- | ------------------------------ |
| serialNumber | number | 是 | 帐号SN码。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 |
**参数:**
- 示例:查询与SN码12345关联的系统帐号的ID
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | --------------------------- | ---- | ------------------------------------------------ |
| serialNumber | number | 是 | 帐号SN码。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 |
**示例:**查询与SN码12345关联的系统帐号的ID
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1371,25 +1576,27 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback&
});
```
### getOsAccountLocalIdBySerialNumber
### getOsAccountLocalIdBySerialNumber<sup>8+</sup>
getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
通过SN码查询与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------ | ---- | ---------- |
| serialNumber | number | 是 | 帐号SN码。 |
| 参数名 | 类型 | 必填 | 说明 |
| ------------ | ------ | ---- | ---------- |
| serialNumber | number | 是 | 帐号SN码。 |
- 返回值:
**返回值:**
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 |
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 |
- 示例:查询与SN码12345关联的系统帐号的ID
**示例:**查询与SN码12345关联的系统帐号的ID
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1401,20 +1608,22 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise&lt;number&gt;
});
```
### getSerialNumberByOsAccountLocalId
### getSerialNumberByOsAccountLocalId<sup>8+</sup>
getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;number&gt;): void
通过系统帐号ID获取与该系统帐号关联的SN码,使用callback回调异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------- | ---- | ------------------------------ |
| localId | number | 是 | 系统帐号ID。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 |
**参数:**
- 示例:获取ID为100的系统帐号关联的SN码
| 参数名 | 类型 | 必填 | 说明 |
| -------- | --------------------------- | ---- | ------------------------------------------ |
| localId | number | 是 | 系统帐号ID。 |
| callback | AsyncCallback&lt;number&gt; | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 |
**示例:**获取ID为100的系统帐号关联的SN码
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1425,25 +1634,27 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback&lt;nu
});
```
### getSerialNumberByOsAccountLocalId
### getSerialNumberByOsAccountLocalId<sup>8+</sup>
getSerialNumberByOsAccountLocalId(localId: number): Promise&lt;number&gt;
通过系统帐号ID获取与该系统帐号关联的SN码,使用Promise方式异步返回结果。
- 参数:
**系统能力:** SystemCapability.Account.OsAccount
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
**参数:**
- 返回值:
| 参数名 | 类型 | 必填 | 说明 |
| ------- | ------ | ---- | ------------ |
| localId | number | 是 | 系统帐号ID。 |
| 类型 | 说明 |
| :-------------- | :---------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 |
**返回值:**
- 示例:获取ID为100的系统帐号关联的SN码
| 类型 | 说明 |
| :-------------------- | :----------------------------------------------------------- |
| Promise&lt;number&gt; | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 |
**示例:**获取ID为100的系统帐号关联的SN码
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1461,15 +1672,21 @@ on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&g
订阅系统帐号的变动信息,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------------ |
| type | 'activate' \| 'activating' | 是 | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 |
| name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。|
| callback | Callback&lt;number&gt; | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 |
**系统能力:** SystemCapability.Account.OsAccount
- 示例:
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
| type | 'activate' \| 'activating' | 是 | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 |
| name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。 |
| callback | Callback&lt;number&gt; | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1485,15 +1702,21 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number
取消订阅系统帐号的变动信息,使用callback回调异步返回结果。
- 参数:
此接口为系统接口,三方应用不支持调用。
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ---------------------------- |
| type | 'activate' \| 'activating' | 是 | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 |
| name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 |
| callback | Callback&lt;number&gt; | 否 | 取消订阅系统帐号变化的回调,默认返回0。 |
**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
- 示例:
**系统能力:** SystemCapability.Account.OsAccount
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
| type | 'activate' \| 'activating' | 是 | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 |
| name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 |
| callback | Callback&lt;number&gt; | 否 | 取消订阅系统帐号变化的回调,默认返回0。 |
**示例:**
```
const accountManager = account_osAccount.getAccountManager();
......@@ -1504,9 +1727,12 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number
```
## OsAccountInfo
系统帐号信息
系统帐号信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。
| 参数名 | 类型 | 必填 | 说明 |
| ----------------- | ---------------------------------- | ---- | ------------------------ |
| ----------------- | ------------------------------------------------------------ | ---- | --------------------------------- |
| localId | number | 是 | 系统帐号ID。 |
| localName | string | 是 | 系统帐号名称。 |
| type | [OsAccountType](#osaccounttype) | 是 | 系统帐号类型 |
......@@ -1522,16 +1748,19 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number
| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 否 | 域帐号信息 |
## DomainAccountInfo
域帐号信息
域帐号信息。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。
| 参数名 | 类型 | 必填 | 说明 |
| ----------------- | ---------------------------------- | ---- | ------------------------ |
| ----------- | ------ | ---- | ---------- |
| domain | string | 是 | 域名。 |
| accountName | string | 是 | 域帐号名。 |
## 系统帐号约束列表
| 约束 | 说明 |
| ----------------- | ------------------- |
| ------------------------------------- | ------------------------------ |
| constraint.wifi | 禁止使用wifi |
| constraint.wifi.set | 禁止配置wifi |
| constraint.locale.set | 禁止配置设备语言 |
......@@ -1542,7 +1771,7 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number
| constraint.unknown.sources.install | 禁止安装未知来源的应用 |
| constraint.global.unknown.app.install | 禁止所有用户安装未知来源的应用 |
| constraint.bluetooth.set | 禁止配置蓝牙 |
| constraint.bluetooth | 禁止使用蓝牙
| constraint.bluetooth | 禁止使用蓝牙 |
| constraint.bluetooth.share | 禁止共享使用蓝牙 |
| constraint.usb.file.transfer | 禁止通过USB传输文件 |
| constraint.credentials.set | 禁止配置用户凭据 |
......
# 了解OpenHarmony
- [了解OpenHarmony开源项目](OpenHarmony-Overview_zh.md)
- [术语](device-dev/glossary/glossary.md)
- 版本说明
- OpenHarmony 3.x Releases
- [OpenHarmony v3.1 Beta (2021-12-31)](release-notes/OpenHarmony-v3.1-beta.md)
- [OpenHarmony v3.0.1 LTS (2022-01-12)](release-notes/OpenHarmony-v3.0.1-LTS.md)
- [OpenHarmony v3.0 LTS (2021-09-30)](release-notes/OpenHarmony-v3.0-LTS.md)
- OpenHarmony 2.x Releases
- [OpenHarmony v2.2 beta2 (2021-08-04)](release-notes/OpenHarmony-v2.2-beta2.md)
- [OpenHarmony 2.0 Canary (2021-06-01)](release-notes/OpenHarmony-2-0-Canary.md)
- OpenHarmony 1.x Releases
- [OpenHarmony v1.1.4 LTS (2022-02-11)](release-notes/OpenHarmony-v1-1-4-LTS.md)
- [OpenHarmony v1.1.3 LTS (2021-09-30)](release-notes/OpenHarmony-v1-1-3-LTS.md)
- [OpenHarmony v1.1.2 LTS (2021-08-04)](release-notes/OpenHarmony-v1.1.2-LTS.md)
- [OpenHarmony 1.1.1 LTS (2021-06-22)](release-notes/OpenHarmony-1-1-1-LTS.md)
- [OpenHarmony 1.1.0 LTS (2021-04-01)](release-notes/OpenHarmony-1-1-0-LTS.md)
- [OpenHarmony 1.0 (2020-09-10)](release-notes/OpenHarmony-1-0.md)
- 贡献
- [参与贡献](contribute/参与贡献.md)
- [行为准则](contribute/行为准则.md)
- [贡献代码](contribute/贡献代码.md)
- [贡献流程](contribute/贡献流程.md)
- [自测试验证](readme/测试子系统.md)
- [贡献文档](contribute/贡献文档.md)
- [写作规范](contribute/写作规范.md)
- [社区沟通与交流](contribute/社区沟通与交流.md)
- [FAQ](contribute/FAQ.md)
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册