Obtains the local root directory of the application. If this method is called for the first time, a root directory is created. This method uses a callback to return the result.
Obtains the local root directory of the application. If this method is called for the first time, a root directory is created. This method uses a promise to return the result.
getOrCreateLocalDir(): Promise\<string>
- Parameters
Obtains the local root directory of the application. This method uses a promise to return the result.
None
If this method is called for the first time, a root directory is created.
- Return values
**Return value**
| Type| Description|
| Type| Description|
| --------------- | -------------------- |
| ---------------- | ---------------------- |
| Promise<string> | Promise used to return the local root directory of the application.|
| Promise\<string> | Promise returned with the local root directory of the application.|
| callback | Read-only| AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| permission | Read-only| string | Yes| Name of the permission to verify.|
| callback | Read-only| AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| permission | string | Yes| Name of the permission to verify.|
| callback | AsyncCallback\<number> | Yes| Callback used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| permission | Read-only| string | Yes| Name of the permission to verify.|
| Promise\<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
| Promise<number> | Promise used to return the permission verification result. The value **0** indicates that the PID and UID have the given permission, and the value **-1** indicates that the PID and UID do not have the given permission.|
Obtains the **ohos.bundle.ElementName** object of the current ability. This method is available only to Page abilities. It uses a callback to return the result.
Obtains the **ohos.bundle.ElementName** object of the current ability. This method uses a callback to return the result.
Obtains the **ohos.bundle.ElementName** object of the current ability. This method is available only to Page abilities. It uses a promise to return the result.
getElementName(): Promise\<ElementName>
- Parameters
Obtains the **ohos.bundle.ElementName** object of the current ability. This method uses a promise to return the result.
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 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.
## Required Permissions
## Required Permissions
| Common Event Macro| Common Event Name| Subscriber Permissions|
| Common Event Macro| Common Event Name| Subscriber Permissions|
| userId | Read-only| number | No| User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| userId | Read-only| number | No| User ID. The default value is the ID of the current user. If this parameter is specified, the value must be an existing user ID in the system.|
| priority | Read-only| number | No| Subscriber priority. The value ranges from -100 to 1000.|
| priority | Read-only| number | No| Subscriber priority. The value ranges from -100 to 1000.|
## <span id = "CommonEventData">CommonEventData</span>
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a callback to return the result.
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a callback to return the result.
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a promise to return the result.
Aborts this common event. After the abort, the common event is not sent to the next subscriber. This method takes effect only for ordered common events. It uses a promise to return the result.
- Example
**Example**
```js
```js
varsubscriber;// Used to save the created subscriber object for subsequent subscription and unsubscription.
varsubscriber;// Used to save the created subscriber object for subsequent subscription and unsubscription.
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a callback to return the result.
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a callback to return the result.
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a promise to return the result.
Checks whether this common event is in the aborted state. This method takes effect only for ordered common events. It uses a promise to return the result.
>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 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.
## Modules to Import<a name="s56d19203690d4782bfc74069abb6bd71"></a>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p2269207135212"><aname="p2269207135212"></a><aname="p2269207135212"></a>The display is in sleep mode.</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p18269153355217"><aname="p18269153355217"></a><aname="p18269153355217"></a>The display is in sleep mode, and the CPU is suspended.</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p15865395215"><aname="p15865395215"></a><aname="p15865395215"></a>The display is in VR mode.</p>
<tdclass="cellrowborder"valign="top"width="59.67%"headers="mcps1.1.4.1.3 "><pid="p396720433521"><aname="p396720433521"></a><aname="p396720433521"></a>The display is powered on, and the CPU is suspended.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p2059719436313"><aname="p2059719436313"></a><aname="p2059719436313"></a>ID of the display.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p165751447416"><aname="p165751447416"></a><aname="p165751447416"></a>Name of the display.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p99144412415"><aname="p99144412415"></a><aname="p99144412415"></a>Whether the display is alive.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p102153564110"><aname="p102153564110"></a><aname="p102153564110"></a>State of the display.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p647315520412"><aname="p647315520412"></a><aname="p647315520412"></a>Refresh rate of the display.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p16808514113"><aname="p16808514113"></a><aname="p16808514113"></a>Screen rotation angle of the display.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p1544266184119"><aname="p1544266184119"></a><aname="p1544266184119"></a>Width of the display, in pixels.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p126490694117"><aname="p126490694117"></a><aname="p126490694117"></a>Height of the display, in pixels.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p29318812312"><aname="p29318812312"></a><aname="p29318812312"></a>Screen density of the display, in DPI.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p422127164110"><aname="p422127164110"></a><aname="p422127164110"></a>Screen density of the display, in pixels.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p132021793429"><aname="p132021793429"></a><aname="p132021793429"></a>Scaling factor for fonts displayed on the display.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p10597843034"><aname="p10597843034"></a><aname="p10597843034"></a>Exact physical dots per inch of the screen in the horizontal direction.</p>
<tdclass="cellrowborder"valign="top"width="37.78%"headers="mcps1.1.6.1.5 "><pid="p2083001718427"><aname="p2083001718427"></a><aname="p2083001718427"></a>Exact physical dots per inch of the screen in the vertical direction.</p>
<td class="cellrowborder" valign="top" width="35.38%" headers="mcps1.1.5.1.4 "><p id="p1790072917218"><a name="p1790072917218"></a><a name="p1790072917218"></a>Callback used to return the attributes of the default display.</p>
</td>
</tr>
</tbody>
</table>
- Example
- Example
```
```
var displayClass = null;
var displayClass = null;
display.getDefaultDisplay((err, data) => {
display.getDefaultDisplay((err, data) => {
...
@@ -289,39 +77,18 @@ Obtains the default display object.
...
@@ -289,39 +77,18 @@ Obtains the default display object.
<td class="cellrowborder" valign="top" width="41.18%" headers="mcps1.1.5.1.4 "><p id="p29812131235"><a name="p29812131235"></a><a name="p29812131235"></a>Callback used to return the attributes of all displays.</p>
</td>
</tr>
</tbody>
</table>
- Example
- Example
```
```
display.getAllDisplay((err, data) => {
display.getAllDisplay((err, data) => {
if (err) {
if (err) {
...
@@ -333,49 +100,19 @@ Obtains all the display objects.
...
@@ -333,49 +100,19 @@ Obtains all the display objects.
| type | string | Yes| Listening type. The available values are as follows: <br/>- **add**: listening for whether a display is added <br/>- **remove**: listening for whether a display is removed <br/>- **change**: listening for whether a display is changed|
</th>
| callback | Callback<number> | Yes| Callback used to return the ID of the display.|
<a name="ul5610203018367"></a><a name="ul5610203018367"></a><ul id="ul5610203018367"><li><strong id="b1574838195610"><a name="b1574838195610"></a><a name="b1574838195610"></a>add</strong>: listening for whether a display is added</li><li><strong id="b51261741175616"><a name="b51261741175616"></a><a name="b51261741175616"></a>remove</strong>: listening for whether a display is removed</li><li><strong id="b18418142145615"><a name="b18418142145615"></a><a name="b18418142145615"></a>change</strong>: listening for whether a display is changed</li></ul>
<td class="cellrowborder" valign="top" width="47.99%" headers="mcps1.1.5.1.4 "><p id="p965485411233"><a name="p965485411233"></a><a name="p965485411233"></a>Callback used to return the ID of the display.</p>
| type | string | Yes| Listening type. The available values are as follows: <br/>- **add**: listening for whether a display is added <br/>- **remove**: listening for whether a display is removed <br/>- **change**: listening for whether a display is changed|
</th>
| callback | Callback<number> | No| Callback used to return the ID of the display.|
<a name="ul20308203893611"></a><a name="ul20308203893611"></a><ul id="ul20308203893611"><li><strong id="b78701755195618"><a name="b78701755195618"></a><a name="b78701755195618"></a>add</strong>: listening for whether a display is added</li><li><strong id="b10430956195611"><a name="b10430956195611"></a><a name="b10430956195611"></a>remove</strong>: listening for whether a display is removed</li><li><strong id="b113699578561"><a name="b113699578561"></a><a name="b113699578561"></a>change</strong>: listening for whether a display is changed</li></ul>
<td class="cellrowborder" valign="top" width="51.9%" headers="mcps1.1.5.1.4 "><p id="p1698722611251"><a name="p1698722611251"></a><a name="p1698722611251"></a>Callback used to return the ID of the display.</p>
| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloggerfaultloginfo)>> | Yes| Callback used to return the fault information array. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned.
| callback | AsyncCallbackArray<Array<[FaultLogInfo](#faultloginfo)>> | Yes| Callback used to return the fault information array. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval. In this case, an error string will be returned.
- Example
- Example
```
```
...
@@ -83,12 +83,12 @@ Obtains the fault information about the current process. This method uses a prom
...
@@ -83,12 +83,12 @@ Obtains the fault information about the current process. This method uses a prom
| Promise<Array<[FaultLogInfo](#faultloggerfaultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.|
| Promise<Array<[FaultLogInfo](#faultloginfo)>> | Promise used to return the fault information array. You can obtain the fault information instance in its **then()** method or use **await**. <br/>The value is the fault information array obtained. If the value is **undefined**, an exception occurs during the information retrieval.|
| callback | Read-only| AsyncCallback\<boolean> | Yes| Callback used to return the result.|
| callback | AsyncCallback\<boolean> | Yes| Callback used to return the result. <br>Returns **true** if the main window of this ability has the focus; returns **false** otherwise.|
* Return values
Returns **true** if the main window of this ability has the focus; returns **false** otherwise.
| deviceId | Read-only| string | Yes| Information about the ability to migrate.|
| deviceId | Read-only| string | Yes| Information about the ability to migrate.|
| reversible | Read-only| boolean | Yes| Whether migration back is supported. Currently, this feature is not supported. This parameter is reserved and can be set to **false**.|
| reversible | Read-only| boolean | Yes| Whether migration back is supported. Currently, this feature is not supported. This parameter is reserved and can be set to **false**.|
| resultCode | Read-only| number | Yes| Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
| resultCode | Read-only| number | Yes| Result code returned after the ability is destroyed. The feature for defining error-specific result codes is coming soon.|
| want | Read-only| [Want](#Want)| No| Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.|
| want | Read-only| [Want](#want)| No| Data returned after the ability is destroyed. You can define the data to be returned. This parameter can be **null**.|
| want | Read-only| [Want](#Want)| Yes| Information about the ability to start.|
| want | Read-only| [Want](#want)| Yes| Information about the ability to start.|
| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.|
| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.|
| want | Read-only| [Want](#Want)| Yes| Information about the ability to start.|
| want | Read-only| [Want](#want)| Yes| Information about the ability to start.|
| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.|
| abilityStartSetting | Read-only| {[key: string]: any} | No| Special attribute of the ability to start. This attribute can be passed in the method call.|
## Want
## Want
...
@@ -358,10 +350,10 @@ var result = particleAbility.disconnectAbility(connId).then((void) => {
...
@@ -358,10 +350,10 @@ var result = particleAbility.disconnectAbility(connId).then((void) => {
## AbilityStartSetting
## AbilityStartSetting
Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**.
The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**.
The **AbilityStartSetting** attribute is an object defined as [key: string]: any. The key is a type of **AbilityStartSetting**, and the value is a type of **AbilityWindowConfiguration**.
Defines special attributes of an ability, for example, **featureAbility.AbilityStartSetting.BOUNDS_KEY**.