diff --git a/en/application-dev/device/figures/en-us_image_0000001196654004.png b/en/application-dev/device/figures/en-us_image_0000001196654004.png new file mode 100644 index 0000000000000000000000000000000000000000..48b1613b6e67f2dd57cd480fdb7fd0312594e049 Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001196654004.png differ diff --git a/en/application-dev/device/figures/en-us_image_0000001226521897.png b/en/application-dev/device/figures/en-us_image_0000001226521897.png new file mode 100644 index 0000000000000000000000000000000000000000..a97bd3bfbcf21cc091ee69cee0b6759b2e864116 Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001226521897.png differ diff --git a/en/application-dev/device/figures/en-us_image_0000001241693881.png b/en/application-dev/device/figures/en-us_image_0000001241693881.png new file mode 100644 index 0000000000000000000000000000000000000000..5c54c71606ce2f81308923d8d4c579f1b9b3ad3c Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001241693881.png differ diff --git a/en/application-dev/device/figures/en-us_image_0000001241733907.png b/en/application-dev/device/figures/en-us_image_0000001241733907.png new file mode 100644 index 0000000000000000000000000000000000000000..d0a680b7138b81e6e9a1e598634b66dd598dd603 Binary files /dev/null and b/en/application-dev/device/figures/en-us_image_0000001241733907.png differ diff --git a/en/application-dev/device/sensor-guidelines.md b/en/application-dev/device/sensor-guidelines.md new file mode 100644 index 0000000000000000000000000000000000000000..88d24d59bc4885135b92302c3446c7c81bd33d5d --- /dev/null +++ b/en/application-dev/device/sensor-guidelines.md @@ -0,0 +1,133 @@ +# 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) diff --git a/en/application-dev/device/sensor-overview.md b/en/application-dev/device/sensor-overview.md new file mode 100644 index 0000000000000000000000000000000000000000..ea75d0b5dfc4a0611d118d5ddb9fbbaac1345bc5 --- /dev/null +++ b/en/application-dev/device/sensor-overview.md @@ -0,0 +1,111 @@ +# 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/s2. | 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/s2. | 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/s2. | 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/s2. | 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
SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR | Game rotation vector sensor
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.
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
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. diff --git a/en/application-dev/reference/apis/js-apis-inputconsumer.md b/en/application-dev/reference/apis/js-apis-inputconsumer.md new file mode 100644 index 0000000000000000000000000000000000000000..3e9a9af045b92543f5e9221b5ffa199c4bf9b054 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inputconsumer.md @@ -0,0 +1,82 @@ +# 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<KeyOption>): 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<KeyOption> | 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<KeyOption>): 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<KeyOption> | 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. | diff --git a/en/application-dev/reference/apis/js-apis-inputdevice.md b/en/application-dev/reference/apis/js-apis-inputdevice.md new file mode 100644 index 0000000000000000000000000000000000000000..0913e6e3ce52acbcf57959768599dde89fed4d87 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inputdevice.md @@ -0,0 +1,109 @@ +# 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<Array<number>>): 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<Array<number>> | 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<InputDeviceData>): 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<[InputDeviceData](#inputdevicedata)> | 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<[SourceType](#sourcetype)> | 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. | diff --git a/en/application-dev/reference/apis/js-apis-inputmonitor.md b/en/application-dev/reference/apis/js-apis-inputmonitor.md new file mode 100644 index 0000000000000000000000000000000000000000..b5cee97142e6e57dc15a967f0e99eea21eb05224 --- /dev/null +++ b/en/application-dev/reference/apis/js-apis-inputmonitor.md @@ -0,0 +1,142 @@ +# 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 of the input event. Currently, only **touch** events are supported. | +| receiver | [TouchEventReceiver](#toucheventreceiver) | Yes | Callback used to return the touch 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 of the input event. Currently, only **touch** events are supported. | +| receiver | [TouchEventReceiver](#toucheventreceiver) | No | Callback used to return the touch 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 used to return the touch event. | + + **Return value** + | Type | Description | +| -------- | -------- | +| Boolean | Result indicating whether the touch event has been consumed by the input monitor. The value **true** indicates that the touch event has been consumed, and the value **false** indicates the 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"); +} +``` diff --git a/en/overview-website-en.md b/en/overview-website-en.md new file mode 100644 index 0000000000000000000000000000000000000000..ae9d754ed82bc293c436393d20c455b9cd4cb9ff --- /dev/null +++ b/en/overview-website-en.md @@ -0,0 +1,31 @@ +# 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 diff --git a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md index a571496b551cfe0aae82c69336dd92d8afaf9abe..99ad55ca4046d399f0b5b23e6a22f030f12601eb 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-appAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-appAccount.md @@ -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<void>): void; +addAccount(name: string, callback: AsyncCallback<void>): void 将此应用的帐号名添加到帐号管理服务中,使用callback回调异步返回结果。 -需要权限:无。 +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ------------------------------------------ | - | name | string | 是 | 要添加的应用帐户的名称。 | - | callback | AsyncCallback<void> | 是 | 将此应用的帐号名添加到帐号管理服务的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------------------------------------ | +| name | string | 是 | 要添加的应用帐户的名称。 | +| callback | AsyncCallback<void> | 是 | 将此应用的帐号名添加到帐号管理服务的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -62,21 +59,21 @@ addAccount(name: string, callback: AsyncCallback<void>): void; ### addAccount -addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void; +addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>): void 将此应用程序的帐号名和额外信息添加到帐号管理服务中,使用callback回调异步返回结果。 -需要权限:无。 +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | 是 | 要添加的应用帐户的名称。 | - | extraInfo | string | 是 | 要添加的应用帐户的额外信息(例如token等),额外的信息不能是应用帐号的敏感信息。 | - | callback | AsyncCallback<void> | 是 | 将此应用程序的帐号名和额外信息添加到帐号管理服务中的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | ------------------------------------------------------------ | +| name | string | 是 | 要添加的应用帐户的名称。 | +| extraInfo | string | 是 | 要添加的应用帐户的额外信息(例如token等),额外的信息不能是应用帐号的敏感信息。 | +| callback | AsyncCallback<void> | 是 | 将此应用程序的帐号名和额外信息添加到帐号管理服务中的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -89,26 +86,26 @@ addAccount(name: string, extraInfo: string, callback: AsyncCallback<void>) ### addAccount -addAccount(name: string, extraInfo?: string): Promise<void>; +addAccount(name: string, extraInfo?: string): Promise<void> 将此应用的帐号名或额外信息添加到帐号管理服务中,使用Promise方式异步返回结果。 -需要权限:无。 +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------ | ---- | ------------------------------------------------------------ | - | name | string | 是 | 要添加的应用帐户的名称。 | - | extraInfo | string | 是 | 要添加的应用帐户的额外信息,额外的信息不能是应用帐号的敏感信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------------------------------------------------ | +| name | string | 是 | 要添加的应用帐户的名称。 | +| extraInfo | string | 是 | 要添加的应用帐户的额外信息,额外的信息不能是应用帐号的敏感信息。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | ------------- | ---------------------------------- | - | Promise<void> | romise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ------------------- | ---------------------------------- | +| Promise<void> | romise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -121,22 +118,22 @@ addAccount(name: string, extraInfo?: string): Promise<void>; ### addAccountImplicitly8+ -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<void>): void; +deleteAccount(name: string, callback: AsyncCallback<void>): void 从帐号管理服务中删除应用帐号,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ---------------------------------- | - | name | string | 是 | 要删除的应用帐户的名称。 | - | callback | AsyncCallback<void> | 是 | 帐号管理服务中删除应用帐号的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------- | +| name | string | 是 | 要删除的应用帐户的名称。 | +| callback | AsyncCallback<void> | 是 | 帐号管理服务中删除应用帐号的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -184,23 +183,25 @@ deleteAccount(name: string, callback: AsyncCallback<void>): void; ### deleteAccount -deleteAccount(name: string): Promise<void>; +deleteAccount(name: string): Promise<void> 从帐号管理服务中删除应用帐号,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------------ | - | name | string | 是 | 要删除的应用帐户的名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------------ | +| name | string | 是 | 要删除的应用帐户的名称。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -213,19 +214,21 @@ deleteAccount(name: string): Promise<void>; ### disableAppAccess -disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void; +disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | 是 | 要禁用访问的第三方应用帐户的名称。 | - | bundleName | string | 是 | 第三方应用的包名。 | - | callback | AsyncCallback<void> | 是 | 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------------------------------------------ | +| name | string | 是 | 要禁用访问的第三方应用帐户的名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | +| callback | AsyncCallback<void> | 是 | 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -236,24 +239,26 @@ disableAppAccess(name: string, bundleName: string, callback: AsyncCallback<vo ### disableAppAccess -disableAppAccess(name: string, bundleName: string): Promise<void>; +disableAppAccess(name: string, bundleName: string): Promise<void> 禁止指定第三方应用帐户的名称访问指定包名称的第三方应用,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------ | ---- | ---------------------------------- | - | name | string | 是 | 要禁用访问的第三方应用帐户的名称。 | - | bundleName | string | 是 | 第三方应用的包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ---------------------------------- | +| name | string | 是 | 要禁用访问的第三方应用帐户的名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -266,19 +271,21 @@ disableAppAccess(name: string, bundleName: string): Promise<void>; ### enableAppAccess -enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void; +enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<void>): void 允许指定第三方应用帐户的名称访问指定包名称的第三方应用,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------- | ---- | ------------------------------------------------------------ | - | name | string | 是 | 应用帐号名称。 | - | bundleName | string | 是 | 第三方应用的包名。 | - | callback | AsyncCallback<void> | 是 | 允许指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------------------------------------------ | +| name | string | 是 | 应用帐号名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | +| callback | AsyncCallback<void> | 是 | 允许指定第三方应用帐户的名称访问指定包名称的第三方应用的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -289,24 +296,26 @@ enableAppAccess(name: string, bundleName: string, callback: AsyncCallback<voi ### enableAppAccess -enableAppAccess(name: string, bundleName: string): Promise<void>; +enableAppAccess(name: string, bundleName: string): Promise<void> 允许指定第三方应用帐户的名称访问指定包名称的第三方应用,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------ | ---- | ------------------ | - | name | string | 是 | 应用帐号名称。 | - | bundleName | string | 是 | 第三方应用的包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------ | +| name | string | 是 | 应用帐号名称。 | +| bundleName | string | 是 | 第三方应用的包名。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` app_account_instance.enableAppAccess("ZhangSan", "com.example.ohos.accountjsdemo").then(() => { @@ -318,20 +327,22 @@ enableAppAccess(name: string, bundleName: string): Promise<void>; ### checkAppAccountSyncEnable -checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void; +checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): void 检查指定应用帐号是否允许应用数据同步,使用callback回调异步返回结果。 -需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | -------------------------------------------- | - | name | string | 是 | 应用帐号名称。 | - | callback | AsyncCallback<boolean> | 是 | 检查指定应用帐号是否允许应用数据同步的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | -------------------------------------------- | +| name | string | 是 | 应用帐号名称。 | +| callback | AsyncCallback<boolean> | 是 | 检查指定应用帐号是否允许应用数据同步的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -343,25 +354,27 @@ checkAppAccountSyncEnable(name: string, callback: AsyncCallback<boolean>): ### checkAppAccountSyncEnable -checkAppAccountSyncEnable(name: string): Promise<boolean>; +checkAppAccountSyncEnable(name: string): Promise<boolean> 检查指定应用帐号是否允许应用数据同步,使用Promise方式异步返回结果。 -需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | -------------- | - | name | string | 是 | 应用帐号名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------- | +| name | string | 是 | 应用帐号名称。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :--------------------- | :---------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -374,20 +387,22 @@ checkAppAccountSyncEnable(name: string): Promise<boolean>; ### setAccountCredential -setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void; +setAccountCredential(name: string, credentialType: string, credential: string,callback: AsyncCallback<void>): void 设置此应用程序帐号的凭据,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------------------- | ---- | ---------------------------- | - | name | string | 是 | 应用程序帐户的名称。 | - | credentialType | string | 是 | 要设置的凭据的类型。 | - | credential | string | 是 | 要设置的凭据。 | - | callback | AsyncCallback<void> | 是 | 设置此应用帐号的凭据的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------------------------- | ---- | ---------------------------- | +| name | string | 是 | 应用程序帐户的名称。 | +| credentialType | string | 是 | 要设置的凭据的类型。 | +| credential | string | 是 | 要设置的凭据。 | +| callback | AsyncCallback<void> | 是 | 设置此应用帐号的凭据的回调。 | + +**示例:** ``` 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<void>; +setAccountCredential(name: string, credentialType: string, credential: string): Promise<void> 设置此应用程序帐号的凭据,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------ | ---- | -------------------- | - | name | string | 是 | 应用帐户的名称。 | - | credentialType | string | 是 | 要设置的凭据的类型。 | - | credential | string | 是 | 要设置的凭据。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | -------------------- | +| name | string | 是 | 应用帐户的名称。 | +| credentialType | string | 是 | 要设置的凭据的类型。 | +| credential | string | 是 | 要设置的凭据。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | 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<void>): void; +setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback<void>): void 设置此应用程序帐号的额外信息,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------------- | ---- | -------------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | extraInfo | string | 是 | 要设置的额外信息。 | - | callback | AsyncCallback<void> | 是 | 设置此应用帐号的额外信息的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------- | ---- | -------------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| extraInfo | string | 是 | 要设置的额外信息。 | +| callback | AsyncCallback<void> | 是 | 设置此应用帐号的额外信息的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -452,24 +471,26 @@ setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback< ### setAccountExtraInfo -setAccountExtraInfo(name: string, extraInfo: string): Promise<void>; +setAccountExtraInfo(name: string, extraInfo: string): Promise<void> 设置此应用程序帐号的额外信息,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------ | ---- | ------------------ | - | name | string | 是 | 应用帐户的名称。 | - | extraInfo | string | 是 | 要设置的额外信息。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------------ | +| name | string | 是 | 应用帐户的名称。 | +| extraInfo | string | 是 | 要设置的额外信息。 | - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -482,21 +503,23 @@ setAccountExtraInfo(name: string, extraInfo: string): Promise<void>; ### setAppAccountSyncEnable -setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void; +setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback<void>): void 设置指定的应用程序帐号是否允许应用程序数据同步,使用callback回调异步返回结果。 -需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | -------------------------------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | isEnable | boolean | 是 | 是否允许应用数据同步。 | - | callback | AsyncCallback<void> | 是 | 设置指定的应用帐号是否允许应用程序数据同步的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------------------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| isEnable | boolean | 是 | 是否允许应用数据同步。 | +| callback | AsyncCallback<void> | 是 | 设置指定的应用帐号是否允许应用程序数据同步的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -507,26 +530,28 @@ setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback ### setAppAccountSyncEnable -setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>; +setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void> 设置指定的应用程序帐号是否允许应用程序数据同步,使用Promise方式异步返回结果。 -需要权限:ohos.permission.DISTRIBUTED_DATASYNC,系统应用可用。 +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC,仅系统应用可用。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------- | ---- | ---------------------- | - | name | string | 是 | 应用帐户的名称。 | - | isEnable | boolean | 是 | 是否允许应用数据同步。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------- | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| isEnable | boolean | 是 | 是否允许应用数据同步。 | - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -539,20 +564,22 @@ setAppAccountSyncEnable(name: string, isEnable: boolean): Promise<void>; ### setAssociatedData -setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void; +setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback<void>): void 设置与此应用程序帐号关联的数据,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ---------------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | key | string | 是 | 要设置的数据的键,密钥可以自定义。 | - | value | string | 是 | 要设置的数据的值。 | - | callback | AsyncCallback<void> | 是 | 设置与此应用帐号关联的数据的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| key | string | 是 | 要设置的数据的键,密钥可以自定义。 | +| value | string | 是 | 要设置的数据的值。 | +| callback | AsyncCallback<void> | 是 | 设置与此应用帐号关联的数据的回调。 | -- 示例: +**示例:** ``` 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<void>; +setAssociatedData(name: string, key: string, value: string): Promise<void> 设置与此应用程序帐号关联的数据,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ---------------------------------- | - | name | string | 是 | 应用帐户的名称。 | - | key | string | 是 | 要设置的数据的键,密钥可以自定义。 | - | value | string | 是 | 要设置的数据的值。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| key | string | 是 | 要设置的数据的键,密钥可以自定义。 | +| value | string | 是 | 要设置的数据的值。 | - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -593,19 +622,21 @@ setAssociatedData(name: string, key: string, value: string): Promise<void> ### getAccountCredential -getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void; +getAccountCredential(name: string, credentialType: string, callback: AsyncCallback<string>): void 获取此应用帐号的凭据,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | --------------------- | ---- | ---------------------------- | - | name | string | 是 | 应用帐号名称。 | - | credentialType | string | 是 | 要获取的凭据的类型。 | - | callback | AsyncCallback<string> | 是 | 获取此应用帐号的凭据的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | --------------------------- | ---- | ---------------------------- | +| name | string | 是 | 应用帐号名称。 | +| credentialType | string | 是 | 要获取的凭据的类型。 | +| callback | AsyncCallback<string> | 是 | 获取此应用帐号的凭据的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -617,24 +648,26 @@ getAccountCredential(name: string, credentialType: string, callback: AsyncCallba ### getAccountCredential -getAccountCredential(name: string, credentialType: string): Promise<string>; +getAccountCredential(name: string, credentialType: string): Promise<string> 获取此应用程序帐号的凭据,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------------- | ------ | ---- | -------------------- | - | name | string | 是 | 应用帐号名称。 | - | credentialType | string | 是 | 要获取的凭据的类型。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| -------------- | ------ | ---- | -------------------- | +| name | string | 是 | 应用帐号名称。 | +| credentialType | string | 是 | 要获取的凭据的类型。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :---------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -647,18 +680,20 @@ getAccountCredential(name: string, credentialType: string): Promise<string> ### getAccountExtraInfo -getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void; +getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void 获取此应用帐号的额外信息,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | -------------------------------- | - | name | string | 是 | 应用帐号名称。 | - | callback | AsyncCallback<string> | 是 | 获取此应用帐号的额外信息的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------------- | +| name | string | 是 | 应用帐号名称。 | +| callback | AsyncCallback<string> | 是 | 获取此应用帐号的额外信息的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -670,23 +705,25 @@ getAccountExtraInfo(name: string, callback: AsyncCallback<string>): void; ### getAccountExtraInfo -getAccountExtraInfo(name: string): Promise<string>; +getAccountExtraInfo(name: string): Promise<string> 获取此应用程序帐号的额外信息,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | -------------- | - | name | string | 是 | 应用帐号名称。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | -------------- | +| name | string | 是 | 应用帐号名称。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :---------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -699,19 +736,21 @@ getAccountExtraInfo(name: string): Promise<string>; ### getAssociatedData -getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void; +getAssociatedData(name: string, key: string, callback: AsyncCallback<string>): void 获取与此应用程序帐号关联的数据,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ---------------------------------- | - | name | string | 是 | 应用帐号名称。 | - | key | string | 是 | 要获取的数据的key。 | - | callback | AsyncCallback<string> | 是 | 获取与此应用帐号关联的数据的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------------------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的key。 | +| callback | AsyncCallback<string> | 是 | 获取与此应用帐号关联的数据的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -723,24 +762,26 @@ getAssociatedData(name: string, key: string, callback: AsyncCallback<string&g ### getAssociatedData -getAssociatedData(name: string, key: string): Promise<string>; +getAssociatedData(name: string, key: string): Promise<string> 获取与此应用程序帐号关联的数据,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------------- | - | name | string | 是 | 应用帐号名称。 | - | key | string | 是 | 要获取的数据的key。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ------------------- | +| name | string | 是 | 应用帐号名称。 | +| key | string | 是 | 要获取的数据的key。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :---------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -753,19 +794,21 @@ getAssociatedData(name: string, key: string): Promise<string>; ### getAllAccessibleAccounts -getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void; +getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>>): void 获取全部应用已授权帐号信息。 -需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。 +**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------ | ---- | ---------------- | - | callback | AsyncCallback<Array<AppAccountInfo>> | 是 | 应用帐号信息列表 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | ---------------- | +| callback | AsyncCallback<Array<AppAccountInfo>> | 是 | 应用帐号信息列表 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -777,19 +820,21 @@ getAllAccessibleAccounts(callback: AsyncCallback<Array<AppAccountInfo>& ### getAllAccessibleAccounts -getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>; +getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>> 获取全部应用已授权帐号信息。 -需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。 +**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 类型 | 说明 | - | ------------------------------ | ----------------------------------- | - | Promise<Array<AppAccountInfo>> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ------------------------------------------ | ----------------------------------- | +| Promise<Array<AppAccountInfo>> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -802,20 +847,22 @@ getAllAccessibleAccounts(): Promise<Array<AppAccountInfo>>; ### getAllAccounts -getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void; +getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo>>): void 获取指定应用全部帐号信息。 -需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。 +**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------ | ---- | ---------------- | - | owner | string | 是 | 应用包名称 | - | callback | AsyncCallback<Array<AppAccountInfo>> | 是 | 应用帐号信息列表 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | ---------------- | +| owner | string | 是 | 应用包名称 | +| callback | AsyncCallback<Array<AppAccountInfo>> | 是 | 应用帐号信息列表 | -- 示例: +**示例:** ``` const appAccountManager = account.createAppAccountManager(); @@ -828,25 +875,27 @@ getAllAccounts(owner: string, callback: AsyncCallback<Array<AppAccountInfo ### getAllAccounts -getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>; +getAllAccounts(owner: string): Promise<Array<AppAccountInfo>> 获取指定应用全部帐号信息。 -需要权限:ohos.permission.GET_ACCOUNTS_PRIVILEGED,系统应用可用。 +**需要权限:** ohos.permission.GET_ACCOUNTS_PRIVILEGED,仅系统应用可用。 + +**系统能力:** SystemCapability.Account.AppAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ---------- | - | owner | string | 是 | 应用包名称 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------- | +| owner | string | 是 | 应用包名称 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------ | ----------------------------------- | - | Promise<Array<AppAccountInfo>> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ------------------------------------------ | ----------------------------------- | +| Promise<Array<AppAccountInfo>> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -860,19 +909,21 @@ getAllAccounts(owner: string): Promise<Array<AppAccountInfo>>; ### on('change') -on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void; +on(type: 'change', owners: Array<string>, callback: Callback<Array<AppAccountInfo>>): void 订阅指定帐号所有者的帐户变更事件,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------- | ---- | ------------------------------------------------------------ | - | type | 'change' | 是 | 关于帐户更改事件,当帐户所有者更新帐户时,订阅者将收到通知。 | - | owners | Array<string> | 是 | 指示帐户的所有者。 | - | callback | Callback<Array<AppAccountInfo>> | 是 | 订阅指定帐号所有者的帐户变更事件的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------- | ---- | ------------------------------------------------------------ | +| type | 'change' | 是 | 关于帐户更改事件,当帐户所有者更新帐户时,订阅者将收到通知。 | +| owners | Array<string> | 是 | 指示帐户的所有者。 | +| callback | Callback<Array<AppAccountInfo>> | 是 | 订阅指定帐号所有者的帐户变更事件的回调。 | + +**示例:** ``` const appAccountManager = account.createAppAccountManager(); @@ -889,18 +940,20 @@ on(type: 'change', owners: Array<string>, callback: Callback<Array<A ### off('change') -off(type: 'change', callback?: Callback<void>): void; +off(type: 'change', callback?: Callback>): void 取消订阅帐号事件,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------- | ---- | ------------------------ | - | type | 'change' | 是 | 关于帐户更改事件。 | - | callback | Callback<void> | 否 | 取消订阅帐号事件的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------- | ---- | ------------------------ | +| type | 'change' | 是 | 关于帐户更改事件。 | +| callback | Callback> | 否 | 取消订阅帐号事件的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account.createAppAccountManager(); @@ -920,21 +973,23 @@ off(type: 'change', callback?: Callback<void>): void; ### authenticate8+ -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 ### getOAuthToken8+ -getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void; +getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback<string>): void 获取指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------------- | ---- | -------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | - | callback | AsyncCallback<string> | 是 | 查询结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| callback | AsyncCallback<string> | 是 | 查询结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -985,25 +1042,27 @@ getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCall ### getOAuthToken8+ -getOAuthToken(name: string, owner: string, authType: string): Promise<string>; +getOAuthToken(name: string, owner: string, authType: string): Promise<string> 获取指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | -------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | - | 类型 | 说明 | - | --------------------- | -------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| --------------------- | ----------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1016,20 +1075,22 @@ getOAuthToken(name: string, owner: string, authType: string): Promise<string& ### setOAuthToken8+ -setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void; +setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback<void>): void 设置指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------- | ---- | ------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | token | string | 是 | OAuth令牌。 | - | callback | AsyncCallback<void> | 是 | 设置结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------- | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | OAuth令牌。 | +| callback | AsyncCallback<void> | 是 | 设置结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1040,25 +1101,27 @@ setOAuthToken(name: string, authType: string, token: string, callback: AsyncCall ### setOAuthToken8+ -setOAuthToken(name: string, authType: string, token: string): Promise<void>; +setOAuthToken(name: string, authType: string, token: string): Promise<void> 设置指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | token | string | 是 | OAuth令牌。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------- | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | OAuth令牌。 | - | 类型 | 说明 | - | ------------------- | -------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ------------------- | ----------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1071,21 +1134,23 @@ setOAuthToken(name: string, authType: string, token: string): Promise<void> ### deleteOAuthToken8+ -deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void; +deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback<void>): void 删除指定应用帐户和鉴权类型的OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------- | ---- | ------------------ | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | - | token | string | 是 | 要删除的OAuth令牌。 | - | callback | AsyncCallback<void> | 是 | 删除结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | 要删除的OAuth令牌。 | +| callback | AsyncCallback<void> | 是 | 删除结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1096,26 +1161,28 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string, c ### deleteOAuthToken8+ -deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void>; +deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise<void> 删除指定应用帐户和鉴权类型的OAuth令牌,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ------------------ | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | authType | string | 是 | 鉴权类型。 | - | token | string | 是 | 要删除的OAuth令牌。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| authType | string | 是 | 鉴权类型。 | +| token | string | 是 | 要删除的OAuth令牌。 | - | 类型 | 说明 | - | ------------------------------ | --------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ------------------- | ----------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1128,21 +1195,23 @@ deleteOAuthToken(name: string, owner: string, authType: string, token: string): ### setOAuthTokenVisibility8+ -setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void; +setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback<void>): void 设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------------- | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | bundleName | string | 是 | 被设置可见性的应用包名。| - | isVisible | boolean | 是 | 是否可见。 | - | callback | AsyncCallback<void> | 是 | 设置结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------------------------- | ---- | ------------------------ | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 被设置可见性的应用包名。 | +| isVisible | boolean | 是 | 是否可见。 | +| callback | AsyncCallback<void> | 是 | 设置结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1153,26 +1222,28 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ### setOAuthTokenVisibility8+ -setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void>; +setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise<void> 设置指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------------- | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | bundleName | string | 是 | 被设置可见性的应用包名。| - | isVisible | boolean | 是 | 是否可见。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------- | ---- | ------------------------ | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 被设置可见性的应用包名。 | +| isVisible | boolean | 是 | 是否可见。 | - | 类型 | 说明 | - | ------------------------------ | --------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ------------------- | ----------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1186,20 +1257,22 @@ setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVi ### checkOAuthTokenVisibility8+ -checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void; +checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback<boolean>): void 检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ---------------------------- | ---- | ---------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | bundleName | string | 是 | 用于检查可见性的应用包名。 | - | callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------- | ---- | -------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 用于检查可见性的应用包名。 | +| callback | AsyncCallback<boolean> | 是 | 检查结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1211,25 +1284,27 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, ca ### checkOAuthTokenVisibility8+ -checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean>; +checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise<boolean> 检查指定鉴权类型的OAuth令牌对特定应用的可见性,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------------------------- | ---- | ---------------------- | - | name | string | 是 | 应用帐户的名称。 | - | authType | string | 是 | 鉴权类型。 | - | bundleName | string | 是 | 用于检查可见性的应用包名。 | +**参数:** -- 参数: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | -------------------------- | +| name | string | 是 | 应用帐户的名称。 | +| authType | string | 是 | 鉴权类型。 | +| bundleName | string | 是 | 用于检查可见性的应用包名。 | - | 类型 | 说明 | - | ------------------------------ | ------------------------ | - | Promise<boolean> | Promise实例,用于获取异步返回结果。 | +**参数:** -- 示例: +| 类型 | 说明 | +| ---------------------- | ----------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1242,19 +1317,21 @@ checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): P ### getAllOAuthTokens8+ -getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void; +getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array<OAuthTokenInfo>>): void 获取指定应用对调用方全部可见的OAuth令牌,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------------------------------------ | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | callback | AsyncCallback<Array<OAuthTokenInfo>> | 是 | 查询结果的回调。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| callback | AsyncCallback<Array<OAuthTokenInfo>> | 是 | 查询结果的回调。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1266,24 +1343,26 @@ getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback<Array& ### getAllOAuthTokens8+ -getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>>; +getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenInfo>> 获取指定应用帐户对调用方可见的全部OAuth令牌,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------ | ----------------------------------- | - | Promise<Array<OAuthTokenInfo>> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ------------------------------------------ | ----------------------------------- | +| Promise<Array<OAuthTokenInfo>> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1296,19 +1375,21 @@ getAllOAuthTokens(name: string, owner: string): Promise<Array<OAuthTokenIn ### getOAuthList8+ -getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void; +getOAuthList(name: string, authType: string, callback: AsyncCallback<Array<string>>): void 获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------------------- | ---- | ------------------ | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | - | callback | AsyncCallback<Array<string>> | 是 | 查询结果的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | +| callback | AsyncCallback<Array<string>> | 是 | 查询结果的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1320,24 +1401,26 @@ getOAuthList(name: string, authType: string, callback: AsyncCallback<Array< ### getOAuthList8+ -getOAuthList(name: string, authType: string): Promise<Array<string>>; +getOAuthList(name: string, authType: string): Promise<Array<string>> 获取指定应用帐户和鉴权类型的OAuth令牌的授权列表,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------ | ---- | ------------------- | - | name | string | 是 | 应用帐户的名称。 | - | owner | string | 是 | 应用帐户的所有者包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| name | string | 是 | 应用帐户的名称。 | +| owner | string | 是 | 应用帐户的所有者包名。 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------ | ------------------------------------ | - | Promise<Array<string>> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ---------------------------------- | ----------------------------------- | +| Promise<Array<string>> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1350,18 +1433,20 @@ getOAuthList(name: string, authType: string): Promise<Array<string>> ### getAuthenticatorCallback8+ -getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void; +getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<AuthenticatorCallback>): void 获取鉴权会话的认证器回调,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------------------------------------ | ---- | -------------- | - | sessionId | string | 是 | 鉴权会话的标识。 | - | callback | AsyncCallback<AuthenticatorCallback> | 是 | 查询结果的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------------------------ | ---- | ---------------- | +| sessionId | string | 是 | 鉴权会话的标识。 | +| callback | AsyncCallback<AuthenticatorCallback> | 是 | 查询结果的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1383,23 +1468,25 @@ getAuthenticatorCallback(sessionId: string, callback: AsyncCallback<Authentic ### getAuthenticatorCallback8+ -getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback>; +getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> 获取鉴权会话的认证器回调,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------ | ---- | -------------- | - | sessionId | string | 是 | 鉴权会话的标识。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ---------------- | +| sessionId | string | 是 | 鉴权会话的标识。 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------------ | -------------------------------- | - | Promise<AuthenticatorCallback> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| ------------------------------------ | ----------------------------------- | +| Promise<AuthenticatorCallback> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1421,18 +1508,20 @@ getAuthenticatorCallback(sessionId: string): Promise<AuthenticatorCallback> ### getAuthenticatorInfo8+ -getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void; +getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo>): void 获取指定应用帐户的认证器信息,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------------------------- | ---- | ------------------- | - | owner | string | 是 | 应用帐户的所有者包名。 | - | callback | AsyncCallback<AuthenticatorInfo> | 是 | 查询结果的回调。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------------------- | ---- | ---------------------- | +| owner | string | 是 | 应用帐户的所有者包名。 | +| callback | AsyncCallback<AuthenticatorInfo> | 是 | 查询结果的回调。 | + +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1444,23 +1533,25 @@ getAuthenticatorInfo(owner: string, callback: AsyncCallback<AuthenticatorInfo ### getAuthenticatorInfo8+ -getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; +getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo> 获取指定应用帐户的认证器信息,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ----- | ------ | ---- | -------------------- | - | owner | string | 是 | 应用帐户的所有者包名。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| owner | string | 是 | 应用帐户的所有者包名。 | -- 参数: +**参数:** - | 类型 | 说明 | - | ------------------------------ | ----------------------------------- | - | Promise<AuthenticatorInfo> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| -------------------------------- | ----------------------------------- | +| Promise<AuthenticatorInfo> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const appAccountManager = account_appAccount.createAppAccountManager(); @@ -1475,26 +1566,32 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; 表示应用帐号信息。 -| 参数名 | 类型 | 必填 | 说明 | -| ----- | ------ | ---- | ---------------- | -| owner | string | 是 | 应用帐户的所有者包名。 | -| name | string | 是 | 应用帐户的名称。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | ---------------------- | +| owner | string | 是 | 应用帐户的所有者包名。 | +| name | string | 是 | 应用帐户的名称。 | ## OAuthTokenInfo8+ 表示OAuth令牌信息。 -| 参数名 | 类型 | 必填 | 说明 | -| -------- | ------ | ---- | -------------- | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------ | ---- | ---------------- | | authType | string | 是 | 令牌的鉴权类型。 | -| token | string | 是 | 令牌的取值。 | +| token | string | 是 | 令牌的取值。 | ## AuthenticatorInfo8+ 表示OAuth认证器信息。 -| 参数名 | 类型 | 必填 | 说明 | -| ------- | ------ | ---- | ------------------ | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | | owner | string | 是 | 认证器的所有者包名。 | | iconId | string | 是 | 认证器的图标标识。 | | labelId | string | 是 | 认证器的标签标识。 | @@ -1503,45 +1600,49 @@ getAuthenticatorInfo(owner: string): Promise<AuthenticatorInfo>; 表示常量的枚举。 -| 名称 | 默认值 | 描述 | -| ----------------------------- | ---------------------- | ----------------------- | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 名称 | 默认值 | 描述 | +| ----------------------------- | ---------------------- | ------------------------- | | ACTION_ADD_ACCOUNT_IMPLICITLY | "addAccountImplicitly" | 表示操作_隐式添加帐号。 | -| ACTION_AUTHENTICATE | "authenticate" | 表示操作_鉴权。 | +| ACTION_AUTHENTICATE | "authenticate" | 表示操作_鉴权。 | | KEY_NAME | "name" | 表示键名_应用帐户名称。 | | KEY_OWNER | "owner" | 表示键名_应用帐户所有者。 | -| KEY_TOKEN | "token" | 表示键名_令牌。 | -| KEY_ACTION | "action" | 表示键名_操作。 | -| KEY_AUTH_TYPE | "authType" | 表示键名_鉴权类型。 | -| KEY_SESSION_ID | "sessionId" | 表示键名_会话标识。 | -| KEY_CALLER_PID | "callerPid" | 表示键名_调用方PID。 | -| KEY_CALLER_UID | "callerUid" | 表示键名_调用方UID。 | +| KEY_TOKEN | "token" | 表示键名_令牌。 | +| KEY_ACTION | "action" | 表示键名_操作。 | +| KEY_AUTH_TYPE | "authType" | 表示键名_鉴权类型。 | +| KEY_SESSION_ID | "sessionId" | 表示键名_会话标识。 | +| KEY_CALLER_PID | "callerPid" | 表示键名_调用方PID。 | +| KEY_CALLER_UID | "callerUid" | 表示键名_调用方UID。 | | KEY_CALLER_BUNDLE_NAME | "callerBundleName" | 表示键名_调用方包名。 | ## ResultCode8+ 表示返回码的枚举。 -| 名称 | 默认值 | 描述 | -| ----------------------------------- | ----- | ---------------------- | -| SUCCESS | 0 | 表示操作成功。 | -| ERROR_ACCOUNT_NOT_EXIST | 10001 | 表示应用帐户不存在。 | -| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | 表示应用帐户服务异常。 | -| ERROR_INVALID_PASSWORD | 10003 | 表示密码无效。 | -| ERROR_INVALID_REQUEST | 10004 | 表示请求无效。 | -| ERROR_INVALID_RESPONSE | 10005 | 表示响应无效。 | -| ERROR_NETWORK_EXCEPTION | 10006 | 表示网络异常。 | -| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | 表示认证器不存在。 | -| ERROR_OAUTH_CANCELED | 10008 | 表示鉴权取消。 | -| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | 表示开放授权列表过大。 | -| ERROR_OAUTH_SERVICE_BUSY | 10010 | 表示开放授权服务忙碌。 | -| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | 表示开放授权服务异常。 | -| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | 表示鉴权会话不存在。 | -| ERROR_OAUTH_TIMEOUT | 10013 | 表示鉴权超时。 | -| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | 表示开放授权令牌不存在。 | -| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | 表示开放授权令牌过多。 | -| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | 表示不支持的鉴权操作。 | -| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | 表示不支持的鉴权类型。 | -| ERROR_PERMISSION_DENIED | 10018 | 表示权限不足。 | +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.AppAccount。 + +| 名称 | 默认值 | 描述 | +| ----------------------------------- | ------ | ------------------------ | +| SUCCESS | 0 | 表示操作成功。 | +| ERROR_ACCOUNT_NOT_EXIST | 10001 | 表示应用帐户不存在。 | +| ERROR_APP_ACCOUNT_SERVICE_EXCEPTION | 10002 | 表示应用帐户服务异常。 | +| ERROR_INVALID_PASSWORD | 10003 | 表示密码无效。 | +| ERROR_INVALID_REQUEST | 10004 | 表示请求无效。 | +| ERROR_INVALID_RESPONSE | 10005 | 表示响应无效。 | +| ERROR_NETWORK_EXCEPTION | 10006 | 表示网络异常。 | +| ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST | 10007 | 表示认证器不存在。 | +| ERROR_OAUTH_CANCELED | 10008 | 表示鉴权取消。 | +| ERROR_OAUTH_LIST_TOO_LARGE | 10009 | 表示开放授权列表过大。 | +| ERROR_OAUTH_SERVICE_BUSY | 10010 | 表示开放授权服务忙碌。 | +| ERROR_OAUTH_SERVICE_EXCEPTION | 10011 | 表示开放授权服务异常。 | +| ERROR_OAUTH_SESSION_NOT_EXIST | 10012 | 表示鉴权会话不存在。 | +| ERROR_OAUTH_TIMEOUT | 10013 | 表示鉴权超时。 | +| ERROR_OAUTH_TOKEN_NOT_EXIST | 10014 | 表示开放授权令牌不存在。 | +| ERROR_OAUTH_TOKEN_TOO_MANY | 10015 | 表示开放授权令牌过多。 | +| ERROR_OAUTH_UNSUPPORT_ACTION | 10016 | 表示不支持的鉴权操作。 | +| ERROR_OAUTH_UNSUPPORT_AUTH_TYPE | 10017 | 表示不支持的鉴权类型。 | +| ERROR_PERMISSION_DENIED | 10018 | 表示权限不足。 | ## AuthenticatorCallback8+ @@ -1549,17 +1650,19 @@ OAuth认证器回调接口。 ### onResult8+ -onResult: (code: number, result: {[key: string]: any}) => void; +onResult: (code: number, result: {[key: string]: any}) => 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}) => void; ### onRequestRedirected8+ -onRequestRedirected: (request: Want) => void; +onRequestRedirected: (request: Want) => void 通知鉴权请求被跳转。 -- 参数: - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ---- | ---- | ------------------ | - | request | Want | 是 | 用于跳转的请求信息。 | +**系统能力:** SystemCapability.Account.AppAccount + +**参数:** +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ---- | ---- | -------------------- | +| request | Want | 是 | 用于跳转的请求信息。 | -- 示例: +**示例:** ``` class MyAuthenticator extends account_appAccount.Authenticator { @@ -1612,34 +1717,38 @@ OAuth认证器基类。 ### addAccountImplicitly8+ -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 | 是 | 认证器回调,用于返回鉴权结果。 | ### authenticate8+ -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 { @@ -1663,4 +1772,4 @@ authenticate(name: string, authType: string, callerBundleName: string, options: return new MyAuthenticator(); } } - ``` + ``` \ No newline at end of file diff --git a/zh-cn/application-dev/reference/apis/js-apis-contact.md b/zh-cn/application-dev/reference/apis/js-apis-contact.md index 48edd1e36de5a4fec25f03a878538979e85d1321..b38bb1077c0231f30df4ee19415a706e85fd5654 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-contact.md +++ b/zh-cn/application-dev/reference/apis/js-apis-contact.md @@ -461,7 +461,7 @@ queryMyCard(attrs?: ContactAttributes): Promise<Contact> ## contact.selectContact -selectContact(AsyncCallback<Array<Contact>>): void +selectContact(callback: AsyncCallback<Array<Contact>>): void 选择联系人,使用callback方式作为异步方法。 diff --git a/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md new file mode 100644 index 0000000000000000000000000000000000000000..49b0847e5a4018f324474e65db36a4c375418adf --- /dev/null +++ b/zh-cn/application-dev/reference/apis/js-apis-inputmonitor.md @@ -0,0 +1,142 @@ +# 输入监听 + + +> ![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"); +} +``` diff --git a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md index a47a4fb0647d085027f123eb3d6e6551aa3f439f..8d18ef6e25d9bb7f84227c4535e4981eee67ba1c 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-osAccount.md +++ b/zh-cn/application-dev/reference/apis/js-apis-osAccount.md @@ -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<void>): void 激活指定系统帐号,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | -------------------- | - | localId | number | 是 | 要激活的系统帐号ID。 | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +**参数:** -- 示例:激活ID为100的系统帐号 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------- | +| localId | number | 是 | 要激活的系统帐号ID。 | +| callback | AsyncCallback<void> | 是 | 回调结果。 | + +**示例:**激活ID为100的系统帐号 ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -70,19 +75,23 @@ activateOsAccount(localId: number): Promise<void> 激活指定系统帐号,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 要激活的系统帐号ID。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | +| localId | number | 是 | 要激活的系统帐号ID。 | - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +**返回值:** -- 示例:激活ID为100的系统帐号 +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:**激活ID为100的系统帐号 ``` const accountManager = account_osAccount.getAccountManager(); var localId = 100; @@ -99,13 +108,15 @@ isMultiOsAccountEnable(callback: AsyncCallback<boolean>): void 判断是否支持多系统帐号,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ------------------------------ | - | callback | AsyncCallback<boolean> | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | --------------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,支持多系统帐号则返回true,否则返回false。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -121,13 +132,15 @@ isMultiOsAccountEnable(): Promise<boolean> 判断是否支持多系统帐号,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,支持多系统帐号则返回true,否则返回false。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -144,14 +157,18 @@ isOsAccountActived(localId: number, callback: AsyncCallback<boolean>): voi 判断指定系统帐号是否处于激活状态,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ------------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | callback | AsyncCallback<boolean> | 是 | 回调结果,处于激活状态则返回true,否则返回false。 | +**参数:** -- 示例:判断ID为100的系统帐号是否处于激活状态 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,处于激活状态则返回true,否则返回false。 | + +**示例:**判断ID为100的系统帐号是否处于激活状态 ``` const accountManager = account_osAccount.getAccountManager(); @@ -168,19 +185,23 @@ isOsAccountActived(localId: number): Promise<boolean> 判断指定系统帐号是否处于激活状态,使用Promise方式异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 | +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,处于激活状态则返回true,否则返回false。 | -- 示例:判断ID为100的系统帐号是否处于激活状态 +**示例:**判断ID为100的系统帐号是否处于激活状态 ``` const accountManager = account_osAccount.getAccountManager(); @@ -196,17 +217,21 @@ isOsAccountActived(localId: number): Promise<boolean> isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback<boolean>): void -判断指定系统帐号是否具有指定[约束](#系统帐号约束列表),使用callback回调异步返回结果。 +判断指定系统帐号是否具有指定约束,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ---------------------- | ---- | ------------------------------ | - | localId | number | 是 | 指定的系统帐号ID。 | - | constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | - | callback | AsyncCallback<boolean> | 是 | 回调结果,具有指定约束则返回true,否则返回false。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例:判断ID为100的系统帐号是否有禁止使用wifi的[约束](#系统帐号约束列表) +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ---------------------------- | ---- | ------------------------------------------------- | +| localId | number | 是 | 指定的系统帐号ID。 | +| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,具有指定约束则返回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<boolean> -判断指定系统帐号是否具有指定[约束](#系统帐号约束列表),使用Promise方式异步返回结果。 +判断指定系统帐号是否具有指定约束,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount -- 参数: +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ---------- | ------ | ---- | ---------------- | - | localId | number | 是 | 指定的系统帐号ID。 | - | constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | ------ | ---- | ------------------------------------- | +| localId | number | 是 | 指定的系统帐号ID。 | +| constraint | string | 是 | 指定的[约束](#系统帐号约束列表)名称。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,具有指定[约束](#系统帐号约束列表)则返回true,否则返回false。 | +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,具有指定约束则返回true,否则返回false。 | -- 示例:判断ID为100的系统帐号是否有禁止使用wifi的[约束](#系统帐号约束列表) +**示例:**判断ID为100的系统帐号是否有禁止使用wifi的约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -254,13 +283,15 @@ isTestOsAccount(callback: AsyncCallback<boolean>): void 检查当前系统帐号是否为测试帐号,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ------------------------------------------ | - | callback | AsyncCallback<boolean> | 是 | 回调结果,是测试帐号则返回true,否则返回false。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ----------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,是测试帐号则返回true,否则返回false。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -276,13 +307,15 @@ isTestOsAccount(): Promise<boolean> 检查当前系统帐号是否为测试帐号,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 | +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,是测试帐号则返回true,否则返回false。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -299,13 +332,15 @@ isOsAccountVerified(callback: AsyncCallback<boolean>): void 检查当前系统帐号是否已验证,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ---------------------------------- | - | callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------- | +| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -321,14 +356,16 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo 检查指定系统帐号是否已验证,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------- | ---- | ---------------------------------- | - | localId | number | 否 | 指定的系统帐号ID。 | - | callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------- | ---- | ------------------------------------------- | +| localId | number | 否 | 指定的系统帐号ID。 | +| callback | AsyncCallback<boolean> | 是 | 回调结果,已验证则返回true,否则返回false。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -340,23 +377,25 @@ isOsAccountVerified(localId: number, callback: AsyncCallback<boolean>): vo ### isOsAccountVerified -isOsAccountVerified(localId: number?): Promise<boolean> +isOsAccountVerified(localId?: number): Promise<boolean> 检查指定系统帐号是否已验证,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 否 | 指定的系统帐号ID。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------------ | +| localId | number | 否 | 指定的系统帐号ID。 | - | 类型 | 说明 | - | :--------------- | :---------------------------------- | - | Promise<boolean> | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :--------------------- | :----------------------------------------------------------- | +| Promise<boolean> | Promise实例,用于获取异步返回结果,已验证则返回true,否则返回false。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -373,14 +412,20 @@ removeOsAccount(localId: number, callback: AsyncCallback<void>): void 删除指定系统帐号,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ------------------------ | - | localId | number | 是 | 要删除的系统帐号ID。 | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | -------------------- | +| localId | number | 是 | 要删除的系统帐号ID。 | +| callback | AsyncCallback<void> | 是 | 回调结果。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -399,19 +444,25 @@ removeOsAccount(localId: number): Promise<void> 删除指定系统帐号,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 要删除的系统帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | +| localId | number | 是 | 要删除的系统帐号ID。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -431,18 +482,24 @@ removeOsAccount(localId: number): Promise<void> setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean,callback: AsyncCallback<void>): void -为指定系统帐号设置/删除[约束](#系统帐号约束列表),使用callback回调异步返回结果。 +为指定系统帐号设置/删除约束返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | ----------- | ------------------- | ---- | ------------------------------- | - | localId | number | 是 | 系统帐号ID。 | - | constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 | - | enable | boolean | 是 | 设置(true)/删除(false) | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS -- 示例:给ID为100的系统帐号设置禁止使用wifi的[约束](#系统帐号约束列表) +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------------- | ---- | -------------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 | +| enable | boolean | 是 | 设置(true)/删除(false) | +| callback | AsyncCallback<void> | 是 | 回调结果。 | + +**示例:**给ID为100的系统帐号设置禁止使用wifi的约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -456,23 +513,29 @@ setOsAccountConstraints(localId: number, constraints: Array<string>, enabl setOsAccountConstraints(localId: number, constraints: Array<string>, enable: boolean): Promise<void> -为指定系统帐号设置/删除[约束](#系统帐号约束列表),使用Promise方式异步返回结果。 +为指定系统帐号设置/删除约束回结果。 + +此接口为系统接口,三方应用不支持调用。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | ----------- | ------------- | ---- | ----------------------- | - | localId | number | 是 | 系统帐号ID。 | - | constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 | - | enable | boolean | 是 | 设置(true)/删除(false)。 | +**系统能力:** SystemCapability.Account.OsAccount -- 返回值: +**参数:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------------------- | ---- | -------------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| constraints | Array<string> | 是 | 待设置/删除的[约束](#系统帐号约束列表)列表。 | +| enable | boolean | 是 | 设置(true)/删除(false)。 | -- 示例:删除ID为100的系统帐号的禁止使用wifi的[约束](#系统帐号约束列表) +**返回值:** + +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:**删除ID为100的系统帐号的禁止使用wifi的约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -490,15 +553,19 @@ setOsAccountName(localId: number, localName: string, callback: AsyncCallback< 设置指定系统帐号的帐号名,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | :-------- | ------------------- | ---- | ------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | localName | string | 是 | 帐号名。 | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| :-------- | ------------------------- | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | +| localName | string | 是 | 帐号名。 | +| callback | AsyncCallback<void> | 是 | 回调结果。 | -- 示例:将ID为100的系统帐号的帐号名设置成demoName +**示例:**将ID为100的系统帐号的帐号名设置成demoName ``` const accountManager = account_osAccount.getAccountManager(); @@ -515,20 +582,24 @@ setOsAccountName(localId: number, localName: string): Promise<void> 设置指定系统帐号的帐号名,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------ | ---- | ----------------------- | - | localId | number | 是 | 系统帐号ID。 | - | localName | string | 是 | 帐号名。 | +**系统能力:** SystemCapability.Account.OsAccount -- 返回值: +**参数:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | +| localName | string | 是 | 帐号名。 | -- 示例:将ID为100的系统帐号的帐号名设置成demoName +**返回值:** + +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:**将ID为100的系统帐号的帐号名设置成demoName ``` const accountManager = account_osAccount.getAccountManager(); @@ -547,13 +618,17 @@ getCreatedOsAccountsCount(callback: AsyncCallback<number>): void 获取已创建的系统帐号数量,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ------------------------------ | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是已创建的系统帐号的数量。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------ | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是已创建的系统帐号的数量。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -569,13 +644,17 @@ getCreatedOsAccountsCount(): Promise<number> 获取已创建的系统帐号数量,使用Promise方式异步返回结果。 -- 返回值: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是已创建的系统帐号的数量。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -592,13 +671,15 @@ getOsAccountLocalIdFromProcess(callback: AsyncCallback<number>): void 获取当前进程所属的系统帐号的帐号ID,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ----------------------------------------- | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | -------------------------------------------------- | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号ID。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -614,13 +695,15 @@ getOsAccountLocalIdFromProcess(): Promise<number> 获取当前进程所属的系统帐号的帐号ID,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号ID。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -637,14 +720,16 @@ getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback<number>): 从进程uid中获取该uid所属的系统帐号的帐号ID,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | --------------------------------------- | - | uid | number | 是 | 进程uid。 | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | --------------------------------------------- | +| uid | number | 是 | 进程uid。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是uid所属的系统帐号的帐号ID。 | -- 示例:查询值为12345678的uid所属的系统帐号的帐号ID +**示例:**查询值为12345678的uid所属的系统帐号的帐号ID ``` const accountManager = account_osAccount.getAccountManager(); @@ -661,19 +746,21 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number> 从进程uid中获取该uid所属的系统帐号的帐号ID,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------- | - | uid | number | 是 | 进程uid。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ------ | ---- | --------- | +| uid | number | 是 | 进程uid。 | - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 | +**返回值:** -- 示例:查询值为12345678的uid所属的系统帐号的帐号ID +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是uid所属的系统帐号的帐号ID。 | + +**示例:**查询值为12345678的uid所属的系统帐号的帐号ID ``` const accountManager = account_osAccount.getAccountManager(); @@ -685,20 +772,24 @@ getOsAccountLocalIdFromUid(uid: number): Promise<number> }); ``` -### getOsAccountLocalIdFromDomain +### getOsAccountLocalIdFromDomain8+ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback<number>): void 根据域帐号信息,获取与其关联的系统帐号的帐号ID。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | --------------------------------------- | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | -------------------------------------------- | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是和域帐号关联的系统帐号ID。 | + +**示例:** ``` var domainInfo = {domain: "testDomain", accountName: "testAccountName"}; @@ -709,25 +800,29 @@ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCall }); ``` -### getOsAccountLocalIdFromDomain +### getOsAccountLocalIdFromDomain8+ getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise<number> 根据域帐号信息,获取与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------ | ------ | ---- | ------------- | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | ------------ | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 | +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是和域帐号关联的系统帐号ID。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -745,13 +840,17 @@ queryMaxOsAccountNumber(callback: AsyncCallback<number>): void 查询允许创建的系统帐号的最大数量,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ---------------------------------- | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是允许创建的系统帐号的最大数量。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------------ | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是允许创建的系统帐号的最大数量。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -767,13 +866,17 @@ queryMaxOsAccountNumber(): Promise<number> 查询允许创建的系统帐号的最大数量,使用Promise方式异步返回结果。 -- 返回值: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是允许创建的系统帐号的最大数量。 | +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是允许创建的系统帐号的最大数量。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -788,16 +891,20 @@ queryMaxOsAccountNumber(): Promise<number> getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array<string>>): void -获取指定系统帐号的全部[约束](#系统帐号约束列表),使用callback回调异步返回结果。 +获取指定系统帐号的全部约束,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | ---------------------------------- | - | localId | number | 是 | 系统帐号ID。 | - | callback | AsyncCallback<Array<string>> | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例:获取ID为100的系统帐号的全部[约束](#系统帐号约束列表) +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------------ | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<Array<string>> | 是 | 回调结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | + +**示例:**获取ID为100的系统帐号的全部约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -812,21 +919,25 @@ getOsAccountAllConstraints(localId: number, callback: AsyncCallback<Array< getOsAccountAllConstraints(localId: number): Promise<Array<string>> -获取指定系统帐号的全部[约束](#系统帐号约束列表),使用Promise方式异步返回结果。 +获取指定系统帐号的全部约束,使用Promise方式异步返回结果。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<Array<string>> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | +**返回值:** -- 示例:获取ID为100的系统帐号的全部[约束](#系统帐号约束列表) +| 类型 | 说明 | +| :--------------------------------- | :----------------------------------------------------------- | +| Promise<Array<string>> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的全部[约束](#系统帐号约束列表)。 | + +**示例:**获取ID为100的系统帐号的全部约束 ``` const accountManager = account_osAccount.getAccountManager(); @@ -844,13 +955,17 @@ queryAllCreatedOsAccounts(callback: AsyncCallback<Array<OsAccountInfo>& 查询已创建的所有系统帐号的信息列表,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ----------------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | 是 | 回调结果,返回的是已创建的所有系统帐号的信息列表。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- | +| callback | AsyncCallback<Array<[OsAccountInfo](#osaccountinfo)>> | 是 | 回调结果,返回的是已创建的所有系统帐号的信息列表。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -866,13 +981,17 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>> 查询已创建的所有系统帐号的信息列表,使用Promise方式异步返回结果。 -- 返回值: +此接口为系统接口,三方应用不支持调用。 + +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :---------------------------- | :---------------------------------- | - | Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise实例,用于获取异步返回结果,返回的是已创建的所有系统帐号的信息列表。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :---------------------------------------------------------- | :----------------------------------------------------------- | +| Promise<Array<[OsAccountInfo](#osaccountinfo)>> | Promise实例,用于获取异步返回结果,返回的是已创建的所有系统帐号的信息列表。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -883,19 +1002,21 @@ queryAllCreatedOsAccounts(): Promise<Array<OsAccountInfo>> }); ``` -### queryActivatedOsAccountIds +### queryActivatedOsAccountIds8+ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): void 查询当前处于激活状态的系统帐号的ID列表,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ----------------------------------- | ---- | -------------------------------- | - | callback | AsyncCallback<Array<number>> | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------- | ---- | ------------------------------------------------------ | +| callback | AsyncCallback<Array<number>> | 是 | 回调结果,返回的是当前处于激活状态的系统帐号的ID列表。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -908,19 +1029,21 @@ queryActivatedOsAccountIds(callback: AsyncCallback<Array<number>>): }); ``` -### queryActivatedOsAccountIds +### queryActivatedOsAccountIds8+ queryActivatedOsAccountIds(): Promise<Array<number>> 查询当前处于激活状态的系统帐号的ID列表,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :---------------------------- | :---------------------------------- | - | Promise<Array<number>> | Promise实例,用于获取异步返回结果,返回的是当前处于激活状态的系统帐号的ID列表。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :--------------------------------- | :----------------------------------------------------------- | +| Promise<Array<number>> | 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<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| :-------- | ---------------------------------------------------- | ---- | ------------------------------------------ | +| localName | string | 是 | 创建的系统帐号的名称。 | +| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -961,20 +1090,26 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf 创建一个系统帐号,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------- | ---- | ---------------- | - | localName | string | 是 | 创建的系统帐号的名称。 | - | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | +**参数:** -- 返回值: +| 参数名 | 类型 | 必填 | 说明 | +| --------- | ------------------------------- | ---- | ---------------------- | +| localName | string | 是 | 创建的系统帐号的名称。 | +| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -985,21 +1120,27 @@ createOsAccount(localName: string, type: OsAccountType): Promise<OsAccountInf }); ``` -### createOsAccountForDomain +### createOsAccountForDomain8+ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback<OsAccountInfo>): void 根据域帐号信息,创建一个系统帐号并将其与域帐号关联,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | :-------- | ---------------------------- | ---- | -------------------- | - | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| :--------- | ---------------------------------------------------- | ---- | ------------------------------------------ | +| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是新创建的系统帐号的信息。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1010,26 +1151,32 @@ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, cal }); ``` -### createOsAccountForDomain +### createOsAccountForDomain8+ createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise<OsAccountInfo> 根据传入的域帐号信息,创建与其关联的系统帐号,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | --------- | ------------- | ---- | ---------------- | - | type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | - | domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| ---------- | --------------------------------------- | ---- | ---------------------- | +| type | [OsAccountType](#osaccounttype) | 是 | 创建的系统帐号的类型。 | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 是 | 域帐号信息。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是新创建的系统帐号的信息。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1047,13 +1194,17 @@ queryCurrentOsAccount(callback: AsyncCallback<OsAccountInfo>): void 查询当前进程所属的系统帐号的信息,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | -------------------------- | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------- | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是当前进程所属的系统帐号信息。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1069,13 +1220,17 @@ queryCurrentOsAccount(): Promise<OsAccountInfo> 查询当前进程所属的系统帐号的信息,使用Promise方式异步返回结果。 -- 返回值: +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**返回值:** - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 | +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号信息。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1092,14 +1247,20 @@ queryOsAccountById(localId: number, callback: AsyncCallback<OsAccountInfo> 查询指定系统帐号的信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | -------------------------- | - | localId | number | 是 | 要查询的系统帐号的ID | - | callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是查到的系统帐号的信息。 | +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION -- 示例:查询ID为100的系统帐号信息 +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------- | +| localId | number | 是 | 要查询的系统帐号的ID | +| callback | AsyncCallback<[OsAccountInfo](#osaccountinfo)> | 是 | 回调结果,返回的是查到的系统帐号的信息。 | + +**示例:**查询ID为100的系统帐号信息 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1116,19 +1277,25 @@ queryOsAccountById(localId: number): Promise<OsAccountInfo> 查询指定系统帐号的信息,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS、ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | -------------------------- | - | localId | number | 是 | 要查询的系统帐号的ID | +**系统能力:** SystemCapability.Account.OsAccount -- 返回值: +**参数:** - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是查到的系统帐号的信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | -------------------- | +| localId | number | 是 | 要查询的系统帐号的ID | -- 示例:查询ID为100的系统帐号信息 +**返回值:** + +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountInfo](#osaccountinfo)> | Promise实例,用于获取异步返回结果,返回的是查到的系统帐号的信息。 | + +**示例:**查询ID为100的系统帐号信息 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1146,13 +1313,15 @@ getOsAccountTypeFromProcess(callback: AsyncCallback<OsAccountType>): void 查询当前进程所属的系统帐号的帐号类型,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ---------------------------- | ---- | ---------------------------------------- | - | callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ---------------------------------------------------- | ---- | ---------------------------------------------------- | +| callback | AsyncCallback<[OsAccountType](#osaccounttype)> | 是 | 回调结果,返回的是当前进程所属的系统帐号的帐号类型。 | -- 示例: +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1168,13 +1337,15 @@ getOsAccountTypeFromProcess(): Promise<OsAccountType> 查询当前进程所属的系统帐号的帐号类型,使用Promise方式异步返回结果。 -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :--------------------- | :---------------------------------- | - | Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :--------------------------------------------- | :----------------------------------------------------------- | +| Promise<[OsAccountType](#osaccounttype)> | Promise实例,用于获取异步返回结果,返回的是当前进程所属的系统帐号的帐号类型。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1191,13 +1362,17 @@ getDistributedVirtualDeviceId(callback: AsyncCallback<string>): void 获取分布式虚拟设备ID,使用callback回调异步返回结果。 -- 参数: +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ---------------------------- | - | callback | AsyncCallback<string> | 是 | 回调结果,返回的是分布式虚拟设备ID。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------ | +| callback | AsyncCallback<string> | 是 | 回调结果,返回的是分布式虚拟设备ID。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1213,13 +1388,17 @@ getDistributedVirtualDeviceId(): Promise<string> 获取分布式虚拟设备ID,使用Promise方式异步返回结果。 -- 返回值: +**需要权限:** ohos.permission.DISTRIBUTED_DATASYNC + +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 | +**返回值:** -- 示例: +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<string> | Promise实例,用于获取异步返回结果,返回的是分布式虚拟设备ID。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1236,14 +1415,20 @@ getOsAccountProfilePhoto(localId: number, callback: AsyncCallback<string>) 获取指定系统帐号的头像信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS + +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | callback | AsyncCallback<string> | 是 | 回调结果,返回的是该系统帐号的头像信息。 | +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ---------------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<string> | 是 | 回调结果,返回的是该系统帐号的头像信息。 | -- 示例:获取ID为100的系统帐号的头像 +**示例:**获取ID为100的系统帐号的头像 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1260,19 +1445,25 @@ getOsAccountProfilePhoto(localId: number): Promise<string> 获取指定系统帐号的头像信息,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS -- 返回值: +**系统能力:** SystemCapability.Account.OsAccount - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<string> | Promise实例,用于获取异步返回结果,返回的是该系统帐号的头像信息。 | +**参数:** -- 示例:获取ID为100的系统帐号的头像 +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | + +**返回值:** + +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<string> | 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 - | 参数名 | 类型 | 必填 | 说明 | - | -------- | ------------------- | ---- | ------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | photo | string | 是 | 头像信息。 | - | callback | AsyncCallback<void> | 是 | 回调结果。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例:给ID为100的系统帐号设置头像 +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ------------------------- | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | +| photo | string | 是 | 头像信息。 | +| callback | AsyncCallback<void> | 是 | 回调结果。 | + +**示例:**给ID为100的系统帐号设置头像 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1318,20 +1515,26 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void> 为指定系统帐号设置头像信息,使用Promise方式异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | - | photo | string | 是 | 头像信息。 | +**系统能力:** SystemCapability.Account.OsAccount -- 返回值: +**参数:** - | 类型 | 说明 | - | :------------ | :---------------------------------- | - | Promise<void> | Promise实例,用于获取异步返回结果。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | +| photo | string | 是 | 头像信息。 | -- 示例:给ID为100的系统帐号设置头像 +**返回值:** + +| 类型 | 说明 | +| :------------------ | :---------------------------------- | +| Promise<void> | Promise实例,用于获取异步返回结果。 | + +**示例:**给ID为100的系统帐号设置头像 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1347,20 +1550,22 @@ setOsAccountProfilePhoto(localId: number, photo: string): Promise<void> }); ``` -### getOsAccountLocalIdBySerialNumber +### getOsAccountLocalIdBySerialNumber8+ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback<number>): void 通过SN码查询与其关联的系统帐号的帐号ID,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | ------------ | --------------------- | ---- | ------------------------------ | - | serialNumber | number | 是 | 帐号SN码。 | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 | +**参数:** -- 示例:查询与SN码12345关联的系统帐号的ID +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | --------------------------- | ---- | ------------------------------------------------ | +| serialNumber | number | 是 | 帐号SN码。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与SN码关联的系统帐号的帐号ID。 | + +**示例:**查询与SN码12345关联的系统帐号的ID ``` const accountManager = account_osAccount.getAccountManager(); @@ -1371,25 +1576,27 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback& }); ``` -### getOsAccountLocalIdBySerialNumber +### getOsAccountLocalIdBySerialNumber8+ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> 通过SN码查询与其关联的系统帐号的帐号ID,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------------ | ------ | ---- | ---------- | - | serialNumber | number | 是 | 帐号SN码。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------------ | ------ | ---- | ---------- | +| serialNumber | number | 是 | 帐号SN码。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 | +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与SN码关联的系统帐号的帐号ID。 | -- 示例:查询与SN码12345关联的系统帐号的ID +**示例:**查询与SN码12345关联的系统帐号的ID ``` const accountManager = account_osAccount.getAccountManager(); @@ -1401,20 +1608,22 @@ getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise<number> }); ``` -### getSerialNumberByOsAccountLocalId +### getSerialNumberByOsAccountLocalId8+ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<number>): void 通过系统帐号ID获取与该系统帐号关联的SN码,使用callback回调异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | --------------------- | ---- | ------------------------------ | - | localId | number | 是 | 系统帐号ID。 | - | callback | AsyncCallback<number> | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 | +**参数:** -- 示例:获取ID为100的系统帐号关联的SN码 +| 参数名 | 类型 | 必填 | 说明 | +| -------- | --------------------------- | ---- | ------------------------------------------ | +| localId | number | 是 | 系统帐号ID。 | +| callback | AsyncCallback<number> | 是 | 回调结果,返回的是与该系统帐号关联的SN码。 | + +**示例:**获取ID为100的系统帐号关联的SN码 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1425,25 +1634,27 @@ getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback<nu }); ``` -### getSerialNumberByOsAccountLocalId +### getSerialNumberByOsAccountLocalId8+ getSerialNumberByOsAccountLocalId(localId: number): Promise<number> 通过系统帐号ID获取与该系统帐号关联的SN码,使用Promise方式异步返回结果。 -- 参数: +**系统能力:** SystemCapability.Account.OsAccount + +**参数:** - | 参数名 | 类型 | 必填 | 说明 | - | ------- | ------ | ---- | ------------ | - | localId | number | 是 | 系统帐号ID。 | +| 参数名 | 类型 | 必填 | 说明 | +| ------- | ------ | ---- | ------------ | +| localId | number | 是 | 系统帐号ID。 | -- 返回值: +**返回值:** - | 类型 | 说明 | - | :-------------- | :---------------------------------- | - | Promise<number> | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 | +| 类型 | 说明 | +| :-------------------- | :----------------------------------------------------------- | +| Promise<number> | Promise实例,用于获取异步返回结果,返回的是与该系统帐号关联的SN码。 | -- 示例:获取ID为100的系统帐号关联的SN码 +**示例:**获取ID为100的系统帐号关联的SN码 ``` const accountManager = account_osAccount.getAccountManager(); @@ -1461,15 +1672,21 @@ on(type: 'activate' | 'activating', name: string, callback: Callback<number&g 订阅系统帐号的变动信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------------- | ---- | ------------------------ | - | type | 'activate' \| 'activating' | 是 | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 | - | name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。| - | callback | Callback<number> | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 | +**系统能力:** SystemCapability.Account.OsAccount -- 示例: +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------------------------------------------------ | +| type | 'activate' \| 'activating' | 是 | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 | +| name | string | 是 | 订阅名称,可自定义,要求非空且长度不超过1024字节。 | +| callback | Callback<number> | 是 | 订阅系统帐号变动信息的回调,表示当前事件对应的系统帐号ID。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1485,15 +1702,21 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number 取消订阅系统帐号的变动信息,使用callback回调异步返回结果。 -- 参数: +此接口为系统接口,三方应用不支持调用。 + +**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION + +**系统能力:** SystemCapability.Account.OsAccount - | 参数名 | 类型 | 必填 | 说明 | - | -------- | -------------------------- | ---- | ---------------------------- | - | type | 'activate' \| 'activating' | 是 | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 | - | name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 | - | callback | Callback<number> | 否 | 取消订阅系统帐号变化的回调,默认返回0。 | +**参数:** -- 示例: +| 参数名 | 类型 | 必填 | 说明 | +| -------- | -------------------------- | ---- | ------------------------------------------------------------ | +| type | 'activate' \| 'activating' | 是 | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 | +| name | string | 是 | 订阅名称,可自定义,,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 | +| callback | Callback<number> | 否 | 取消订阅系统帐号变化的回调,默认返回0。 | + +**示例:** ``` const accountManager = account_osAccount.getAccountManager(); @@ -1504,45 +1727,51 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number ``` ## OsAccountInfo -系统帐号信息 -| 参数名 | 类型 | 必填 | 说明 | -| ----------------- | ---------------------------------- | ---- | ------------------------ | -| localId | number | 是 | 系统帐号ID。 | -| localName | string | 是 | 系统帐号名称。 | -| type | [OsAccountType](#osaccounttype) | 是 | 系统帐号类型 | -| constraints | Array<string> | 否 | 系统帐号[约束](#系统帐号约束列表) | -| isVerified | boolean | 是 | 帐号是否锁屏 | -| photo | string | 否 | 系统帐号头像 | -| createTime | number | 是 | 系统帐号创建时间 | -| lastLoginTime | number | 否 | 系统帐号最后一次登录时间 | -| serialNumber | number | 是 | 系统帐号SN码 | -| isActived | boolean | 是 | 系统帐号激活状态 | -| isCreateCompleted | boolean | 是 | 系统帐号创建是否完整 | -| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | 否 | 分布式帐号信息 | -| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 否 | 域帐号信息 | +系统帐号信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ----------------- | ------------------------------------------------------------ | ---- | --------------------------------- | +| localId | number | 是 | 系统帐号ID。 | +| localName | string | 是 | 系统帐号名称。 | +| type | [OsAccountType](#osaccounttype) | 是 | 系统帐号类型 | +| constraints | Array<string> | 否 | 系统帐号[约束](#系统帐号约束列表) | +| isVerified | boolean | 是 | 帐号是否锁屏 | +| photo | string | 否 | 系统帐号头像 | +| createTime | number | 是 | 系统帐号创建时间 | +| lastLoginTime | number | 否 | 系统帐号最后一次登录时间 | +| serialNumber | number | 是 | 系统帐号SN码 | +| isActived | boolean | 是 | 系统帐号激活状态 | +| isCreateCompleted | boolean | 是 | 系统帐号创建是否完整 | +| distributedInfo | [distributedAccount.DistributedInfo](js-apis-distributed-account.md) | 否 | 分布式帐号信息 | +| domainInfo | [DomainAccountInfo](#domainaccountinfo) | 否 | 域帐号信息 | ## DomainAccountInfo -域帐号信息 -| 参数名 | 类型 | 必填 | 说明 | -| ----------------- | ---------------------------------- | ---- | ------------------------ | -| domain | string | 是 | 域名。 | -| accountName | string | 是 | 域帐号名。 | +域帐号信息。 + +**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount。 + +| 参数名 | 类型 | 必填 | 说明 | +| ----------- | ------ | ---- | ---------- | +| domain | string | 是 | 域名。 | +| accountName | string | 是 | 域帐号名。 | ## 系统帐号约束列表 -| 约束 | 说明 | -| ----------------- | ------------------- | -| constraint.wifi | 禁止使用wifi | -| constraint.wifi.set | 禁止配置wifi | -| constraint.locale.set | 禁止配置设备语言 | -| constraint.app.accounts | 禁止添加和删除应用帐号 | -| constraint.apps.install | 禁止安装应用 | -| constraint.apps.uninstall | 禁止卸载应用 | -| constraint.location.shared | 禁止打开位置共享 | -| constraint.unknown.sources.install | 禁止安装未知来源的应用 | +| 约束 | 说明 | +| ------------------------------------- | ------------------------------ | +| constraint.wifi | 禁止使用wifi | +| constraint.wifi.set | 禁止配置wifi | +| constraint.locale.set | 禁止配置设备语言 | +| constraint.app.accounts | 禁止添加和删除应用帐号 | +| constraint.apps.install | 禁止安装应用 | +| constraint.apps.uninstall | 禁止卸载应用 | +| constraint.location.shared | 禁止打开位置共享 | +| constraint.unknown.sources.install | 禁止安装未知来源的应用 | | constraint.global.unknown.app.install | 禁止所有用户安装未知来源的应用 | -| constraint.bluetooth.set | 禁止配置蓝牙 | -| constraint.bluetooth | 禁止使用蓝牙 +| constraint.bluetooth.set | 禁止配置蓝牙 | +| constraint.bluetooth | 禁止使用蓝牙 | | constraint.bluetooth.share | 禁止共享使用蓝牙 | | constraint.usb.file.transfer | 禁止通过USB传输文件 | | constraint.credentials.set | 禁止配置用户凭据 | @@ -1594,4 +1823,4 @@ off(type: 'activate' | 'activating', name: string, callback?: Callback<number | constraint.ambient.display | 禁止显示环境 | | constraint.screen.timeout.set | 禁止配置屏幕关闭的超时 | | constraint.print | 禁止打印 | -| constraint.private.dns.set | 禁止配置专用DNS | +| constraint.private.dns.set | 禁止配置专用DNS | \ No newline at end of file diff --git a/zh-cn/overview-website.md b/zh-cn/overview-website.md new file mode 100644 index 0000000000000000000000000000000000000000..385f5d06bd2d926acedc14a3c3838a982f3c8506 --- /dev/null +++ b/zh-cn/overview-website.md @@ -0,0 +1,36 @@ +# 了解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