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

!8118 翻译已完成6960&7188&7278

Merge pull request !8118 from shawn_he/6960-a
...@@ -14,49 +14,49 @@ The following table describes APIs available for obtaining device location infor ...@@ -14,49 +14,49 @@ The following table describes APIs available for obtaining device location infor
**Table 1** APIs for obtaining device location information **Table 1** APIs for obtaining device location information
| API | Description | | API | Description |
| -------- | -------- | | ------------------------------------------------------------ | ------------------------------------------------------------ |
| on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated. | | on(type: 'locationChange', request: LocationRequest, callback: Callback<Location>) : void | Registers a listener for location changes with a location request initiated. |
| off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted. | | off(type: 'locationChange', callback?: Callback<Location>) : void | Unregisters the listener for location changes with the corresponding location request deleted. |
| on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events. | | on(type: 'locationServiceState', callback: Callback<boolean>) : void | Registers a listener for location service status change events. |
| off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events. | | off(type: 'locationServiceState', callback: Callback<boolean>) : void | Unregisters the listener for location service status change events. |
| on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports. | | on(type: 'cachedGnssLocationsReporting', request: CachedGnssLoactionsRequest, callback: Callback<Array<Location>>) : void; | Registers a listener for cached GNSS location reports. |
| off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports. | | off(type: 'cachedGnssLocationsReporting', callback?: Callback<Array<Location>>) : void; | Unregisters the listener for cached GNSS location reports. |
| on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events. | | on(type: 'gnssStatusChange', callback: Callback<SatelliteStatusInfo>) : void; | Registers a listener for satellite status change events. |
| off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events. | | off(type: 'gnssStatusChange', callback?: Callback<SatelliteStatusInfo>) : void; | Unregisters the listener for satellite status change events. |
| on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events. | | on(type: 'nmeaMessageChange', callback: Callback<string>) : void; | Registers a listener for GNSS NMEA message change events. |
| off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events. | | off(type: 'nmeaMessageChange', callback?: Callback<string>) : void; | Unregisters the listener for GNSS NMEA message change events. |
| on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence. | | on(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Registers a listener for status change events of the specified geofence. |
| off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence. | | off(type: 'fenceStatusChange', request: GeofenceRequest, want: WantAgent) : void; | Unregisters the listener for status change events of the specified geofence. |
| getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This function uses an asynchronous callback to return the result. | | getCurrentLocation(request: CurrentLocationRequest, callback: AsyncCallback<Location>) : void | Obtains the current location. This API uses an asynchronous callback to return the result. |
| getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This function uses a promise to return the result. | | getCurrentLocation(request?: CurrentLocationRequest) : Promise<Location> | Obtains the current location. This API uses a promise to return the result. |
| getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This function uses an asynchronous callback to return the result. | | getLastLocation(callback: AsyncCallback<Location>) : void | Obtains the previous location. This API uses an asynchronous callback to return the result. |
| getLastLocation() : Promise<Location> | Obtains the previous location. This function uses a promise to return the result. | | getLastLocation() : Promise<Location> | Obtains the previous location. This API uses a promise to return the result. |
| isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This function uses an asynchronous callback to return the result. | | isLocationEnabled(callback: AsyncCallback<boolean>) : void | Checks whether the location service is enabled. This API uses an asynchronous callback to return the result. |
| isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This function uses a promise to return the result. | | isLocationEnabled() : Promise<boolean> | Checks whether the location service is enabled. This API uses a promise to return the result. |
| requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This function uses an asynchronous callback to return the result. | | requestEnableLocation(callback: AsyncCallback<boolean>) : void | Requests to enable the location service. This API uses an asynchronous callback to return the result. |
| requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This function uses a promise to return the result. | | requestEnableLocation() : Promise<boolean> | Requests to enable the location service. This API uses a promise to return the result. |
| enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This function uses an asynchronous callback to return the result. | | enableLocation(callback: AsyncCallback<boolean>) : void | Enables the location service. This API uses an asynchronous callback to return the result. |
| enableLocation() : Promise<boolean> | Enables the location service. This function uses a promise to return the result. | | enableLocation() : Promise<boolean> | Enables the location service. This API uses a promise to return the result. |
| disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This function uses an asynchronous callback to return the result. | | disableLocation(callback: AsyncCallback<boolean>) : void | Disables the location service. This API uses an asynchronous callback to return the result. |
| disableLocation() : Promise<boolean> | Disables the location service. This function uses a promise to return the result. | | disableLocation() : Promise<boolean> | Disables the location service. This API uses a promise to return the result. |
| getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This function uses an asynchronous callback to return the result. | | getCachedGnssLocationsSize(callback: AsyncCallback<number>) : void; | Obtains the number of cached GNSS locations. This API uses an asynchronous callback to return the result. |
| getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This function uses a promise to return the result. | | getCachedGnssLocationsSize() : Promise<number>; | Obtains the number of cached GNSS locations. This API uses a promise to return the result. |
| flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses an asynchronous callback to return the result. | | flushCachedGnssLocations(callback: AsyncCallback<boolean>) : void; | Obtains all cached GNSS locations and clears the GNSS cache queue. This API uses an asynchronous callback to return the result.|
| flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This function uses a promise to return the result. | | flushCachedGnssLocations() : Promise<boolean>; | Obtains all cached GNSS locations and clears the GNSS cache queue. This API uses a promise to return the result.|
| sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This function uses an asynchronous callback to return the result. | | sendCommand(command: LocationCommand, callback: AsyncCallback<boolean>) : void; | Sends extended commands to the location subsystem. This API uses an asynchronous callback to return the result.|
| sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This function uses a promise to return the result. | | sendCommand(command: LocationCommand) : Promise<boolean>; | Sends extended commands to the location subsystem. This API uses a promise to return the result. |
| isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This function uses an asynchronous callback to return the result. | | isLocationPrivacyConfirmed(type : LocationPrivacyType, callback: AsyncCallback<boolean>) : void; | Checks whether a user agrees with the privacy statement of the location service. This API uses an asynchronous callback to return the result.|
| isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This function uses a promise to return the result. | | isLocationPrivacyConfirmed(type : LocationPrivacyType,) : Promise<boolean>; | Checks whether a user agrees with the privacy statement of the location service. This API uses a promise to return the result.|
| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This function uses an asynchronous callback to return the result. | | setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean, callback: AsyncCallback<boolean>) : void; | Sets the user confirmation status for the privacy statement of the location service. This API uses an asynchronous callback to return the result.|
| setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This function uses a promise to return the result. | | setLocationPrivacyConfirmStatus(type : LocationPrivacyType, isConfirmed : boolean) : Promise<boolean>; | Sets the user confirmation status for the privacy statement of the location service. This API uses a promise to return the result.|
## How to Develop ## How to Develop
To learn more about the APIs for obtaining device location information, see [Geolocation](../reference/apis/js-apis-geolocation.md). To learn more about the APIs for obtaining device location information, see [Geolocation](../reference/apis/js-apis-geolocation.md).
1. Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user. For details, see the following section. 1. Before using basic location capabilities, check whether your application has been granted the permission to access the device location information. If not, your application needs to obtain the permission from the user as described below.
The system provides the following location permissions: The system provides the following location permissions:
- ohos.permission.LOCATION - ohos.permission.LOCATION
...@@ -64,9 +64,9 @@ To learn more about the APIs for obtaining device location information, see [Geo ...@@ -64,9 +64,9 @@ To learn more about the APIs for obtaining device location information, see [Geo
The **ohos.permission.LOCATION** permission is a must if your application needs to access the device location information. The **ohos.permission.LOCATION** permission is a must if your application needs to access the device location information.
If your application needs to access the device location information when running on the background, it must be allowed to run on the background in the configuration file and also granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information even when your application moves to the background. If your application needs to access the device location information when running on the background, it must be configured to be able to run on the background and be granted the **ohos.permission.LOCATION_IN_BACKGROUND** permission. In this way, the system continues to report device location information after your application moves to the background.
To allow your application to access device location information, you can declare the required permissions in the **config.json** file of your application. The sample code is as follows: To allow your application to access device location information, declare the required permissions in the **module.json** file of your application. The sample code is as follows:
``` ```
...@@ -83,8 +83,8 @@ To learn more about the APIs for obtaining device location information, see [Geo ...@@ -83,8 +83,8 @@ To learn more about the APIs for obtaining device location information, see [Geo
} }
} }
``` ```
For details about the fields, see . For details about these fields, see [Application Package Structure Configuration File](../quick-start/stage-structure.md).
2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities. 2. Import the **geolocation** module by which you can implement all APIs related to the basic location capabilities.
...@@ -93,6 +93,7 @@ To learn more about the APIs for obtaining device location information, see [Geo ...@@ -93,6 +93,7 @@ To learn more about the APIs for obtaining device location information, see [Geo
``` ```
3. Instantiate the **LocationRequest** object. This object provides APIs to notify the system of the location service type and the interval of reporting location information. 3. Instantiate the **LocationRequest** object. This object provides APIs to notify the system of the location service type and the interval of reporting location information.
**Method 1:** **Method 1:**
To better serve your needs for using APIs, the system has categorized APIs into different packages to match your common use cases of the location function. In this way, you can directly use the APIs specific to a certain use case, making application development much easier. The following table lists the use cases currently supported. To better serve your needs for using APIs, the system has categorized APIs into different packages to match your common use cases of the location function. In this way, you can directly use the APIs specific to a certain use case, making application development much easier. The following table lists the use cases currently supported.
...@@ -112,15 +113,15 @@ To learn more about the APIs for obtaining device location information, see [Geo ...@@ -112,15 +113,15 @@ To learn more about the APIs for obtaining device location information, see [Geo
**Table 2** Common use cases of the location function **Table 2** Common use cases of the location function
| Use Case | Constant | Description | | Use Case | Constant | Description |
| -------- | -------- | -------- | | ------------ | ------------------- | ------------------------------------------------------------ |
| Navigation | NAVIGATION | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;obtain&nbsp;the&nbsp;real-time&nbsp;location&nbsp;of&nbsp;a&nbsp;mobile&nbsp;device&nbsp;outdoors,&nbsp;such&nbsp;as&nbsp;navigation&nbsp;for&nbsp;driving&nbsp;or&nbsp;walking.&nbsp;In&nbsp;this&nbsp;scenario,&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology&nbsp;is&nbsp;mainly&nbsp;used&nbsp;to&nbsp;ensure&nbsp;the&nbsp;location&nbsp;accuracy.&nbsp;However,&nbsp;due&nbsp;to&nbsp;its&nbsp;limitations,&nbsp;the&nbsp;technology&nbsp;may&nbsp;be&nbsp;unable&nbsp;to&nbsp;provide&nbsp;the&nbsp;location&nbsp;service&nbsp;when&nbsp;navigation&nbsp;is&nbsp;just&nbsp;started&nbsp;or&nbsp;when&nbsp;the&nbsp;user&nbsp;moves&nbsp;into&nbsp;a&nbsp;shielded&nbsp;environment&nbsp;such&nbsp;as&nbsp;indoors&nbsp;or&nbsp;a&nbsp;garage.&nbsp;To&nbsp;resolve&nbsp;this&nbsp;issue,&nbsp;the&nbsp;system&nbsp;uses&nbsp;the&nbsp;network&nbsp;positioning&nbsp;technology&nbsp;as&nbsp;an&nbsp;alternative&nbsp;to&nbsp;provide&nbsp;the&nbsp;location&nbsp;service&nbsp;for&nbsp;your&nbsp;application&nbsp;until&nbsp;the&nbsp;GNSS&nbsp;can&nbsp;provide&nbsp;stable&nbsp;location&nbsp;results.&nbsp;This&nbsp;helps&nbsp;achieve&nbsp;a&nbsp;smooth&nbsp;navigation&nbsp;experience&nbsp;for&nbsp;users.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. | | Navigation | NAVIGATION | Applicable when your application needs to obtain the real-time location of a mobile device outdoors, such as navigation for driving or walking. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy. However, due to its limitations, the technology may be unable to provide the location service when navigation is just started or when the user moves into a shielded environment such as indoors or a garage. To resolve this issue, the system uses the network positioning technology as an alternative to provide the location service for your application until the GNSS can provide stable location results. This helps achieve a smooth navigation experience for users.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.|
| Trajectory&nbsp;tracking | TRAJECTORY_TRACKING | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;record&nbsp;user&nbsp;trajectories,&nbsp;for&nbsp;example,&nbsp;the&nbsp;track&nbsp;recording&nbsp;function&nbsp;of&nbsp;sports&nbsp;applications.&nbsp;In&nbsp;this&nbsp;scenario,&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology&nbsp;is&nbsp;mainly&nbsp;used&nbsp;to&nbsp;ensure&nbsp;the&nbsp;location&nbsp;accuracy.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. | | Trajectory tracking| TRAJECTORY_TRACKING | Applicable when your application needs to record user trajectories, for example, the track recording function of sports applications. In this scenario, the GNSS positioning technology is mainly used to ensure the location accuracy.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.|
| Ride&nbsp;hailing | CAR_HAILING | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;needs&nbsp;to&nbsp;obtain&nbsp;the&nbsp;current&nbsp;location&nbsp;of&nbsp;a&nbsp;user&nbsp;who&nbsp;is&nbsp;hailing&nbsp;a&nbsp;taxi.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. | | Ride hailing| CAR_HAILING | Applicable when your application needs to obtain the current location of a user who is hailing a taxi.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.|
| Life&nbsp;service | DAILY_LIFE_SERVICE | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;only&nbsp;needs&nbsp;the&nbsp;approximate&nbsp;user&nbsp;location&nbsp;for&nbsp;recommendations&nbsp;and&nbsp;push&nbsp;notifications&nbsp;in&nbsp;scenarios&nbsp;such&nbsp;as&nbsp;when&nbsp;the&nbsp;user&nbsp;is&nbsp;browsing&nbsp;news,&nbsp;shopping&nbsp;online,&nbsp;and&nbsp;ordering&nbsp;food.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. | | Life service| DAILY_LIFE_SERVICE | Applicable when your application only needs the approximate user location for recommendations and push notifications in scenarios such as when the user is browsing news, shopping online, and ordering food.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.|
| Power&nbsp;efficiency | NO_POWER | Applicable&nbsp;when&nbsp;your&nbsp;application&nbsp;does&nbsp;not&nbsp;proactively&nbsp;start&nbsp;the&nbsp;location&nbsp;service&nbsp;for&nbsp;a&nbsp;higher&nbsp;battery&nbsp;efficiency.&nbsp;When&nbsp;responding&nbsp;to&nbsp;another&nbsp;application&nbsp;requesting&nbsp;the&nbsp;same&nbsp;location&nbsp;service,&nbsp;the&nbsp;system&nbsp;marks&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;location&nbsp;result&nbsp;to&nbsp;your&nbsp;application.&nbsp;In&nbsp;this&nbsp;way,&nbsp;your&nbsp;application&nbsp;will&nbsp;not&nbsp;consume&nbsp;extra&nbsp;power&nbsp;for&nbsp;obtaining&nbsp;the&nbsp;user&nbsp;location.<br/>By&nbsp;default,&nbsp;the&nbsp;system&nbsp;reports&nbsp;location&nbsp;results&nbsp;at&nbsp;a&nbsp;minimal&nbsp;interval&nbsp;of&nbsp;1s.&nbsp;To&nbsp;adopt&nbsp;this&nbsp;use&nbsp;case,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. | | Power efficiency | NO_POWER | Applicable when your application does not proactively start the location service for a higher battery efficiency. When responding to another application requesting the same location service, the system marks a copy of the location result to your application. In this way, your application will not consume extra power for obtaining the user location.<br>By default, the system reports location results at a minimal interval of 1s. To adopt this use case, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.|
The following example instantiates the **RequestParam** object for navigation: Sample code for initializing **requestInfo** for navigation:
``` ```
var requestInfo = {'scenario': geolocation.LocationRequestScenario.NAVIGATION, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; var requestInfo = {'scenario': geolocation.LocationRequestScenario.NAVIGATION, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
...@@ -143,20 +144,20 @@ To learn more about the APIs for obtaining device location information, see [Geo ...@@ -143,20 +144,20 @@ To learn more about the APIs for obtaining device location information, see [Geo
**Table 3** Location priority policies **Table 3** Location priority policies
| Policy | Constant | Description | | Policy | Constant | Description |
| -------- | -------- | -------- | | ------------------ | -------------- | ------------------------------------------------------------ |
| Location&nbsp;accuracy&nbsp;priority | ACCURACY | This&nbsp;policy&nbsp;mainly&nbsp;uses&nbsp;the&nbsp;GNSS&nbsp;positioning&nbsp;technology.&nbsp;In&nbsp;an&nbsp;open&nbsp;area,&nbsp;the&nbsp;technology&nbsp;can&nbsp;achieve&nbsp;the&nbsp;meter-level&nbsp;location&nbsp;accuracy,&nbsp;depending&nbsp;on&nbsp;the&nbsp;hardware&nbsp;performance&nbsp;of&nbsp;the&nbsp;device.&nbsp;However,&nbsp;in&nbsp;a&nbsp;shielded&nbsp;environment,&nbsp;the&nbsp;location&nbsp;accuracy&nbsp;may&nbsp;significantly&nbsp;decrease.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. | | Location accuracy priority | ACCURACY | This policy mainly uses the GNSS positioning technology. In an open area, the technology can achieve the meter-level location accuracy, depending on the hardware performance of the device. However, in a shielded environment, the location accuracy may significantly decrease.<br>To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.|
| Fast&nbsp;location&nbsp;priority | FAST_FIRST_FIX | This&nbsp;policy&nbsp;uses&nbsp;the&nbsp;GNSS&nbsp;positioning,&nbsp;base&nbsp;station&nbsp;positioning,&nbsp;WLAN&nbsp;positioning,&nbsp;and&nbsp;Bluetooth&nbsp;positioning&nbsp;technologies&nbsp;simultaneously&nbsp;to&nbsp;obtain&nbsp;the&nbsp;device&nbsp;location&nbsp;in&nbsp;both&nbsp;the&nbsp;indoor&nbsp;and&nbsp;outdoor&nbsp;scenarios.&nbsp;When&nbsp;all&nbsp;positioning&nbsp;technologies&nbsp;provide&nbsp;a&nbsp;location&nbsp;result,&nbsp;the&nbsp;system&nbsp;provides&nbsp;the&nbsp;most&nbsp;accurate&nbsp;location&nbsp;result&nbsp;for&nbsp;your&nbsp;application.&nbsp;This&nbsp;policy&nbsp;can&nbsp;lead&nbsp;to&nbsp;significant&nbsp;hardware&nbsp;resource&nbsp;consumption&nbsp;and&nbsp;power&nbsp;consumption.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. | | Fast location priority | FAST_FIRST_FIX | This policy uses the GNSS positioning, base station positioning, WLAN positioning, and Bluetooth positioning technologies simultaneously to obtain the device location in both the indoor and outdoor scenarios. When all positioning technologies provide a location result, the system provides the most accurate location result for your application. This policy can lead to significant hardware resource consumption and power consumption.<br>To use this policy, you must declare the **ohos.permission.LOCATION** permission and obtain users' authorization.|
| Power&nbsp;efficiency&nbsp;priority | LOW_POWER | This&nbsp;policy&nbsp;mainly&nbsp;uses&nbsp;the&nbsp;base&nbsp;station&nbsp;positioning,&nbsp;WLAN&nbsp;positioning,&nbsp;and&nbsp;Bluetooth&nbsp;positioning&nbsp;technologies&nbsp;to&nbsp;obtain&nbsp;device&nbsp;location&nbsp;in&nbsp;both&nbsp;indoor&nbsp;and&nbsp;outdoor&nbsp;scenarios.&nbsp;The&nbsp;location&nbsp;accuracy&nbsp;depends&nbsp;on&nbsp;the&nbsp;distribution&nbsp;of&nbsp;surrounding&nbsp;base&nbsp;stations,&nbsp;visible&nbsp;WLANs,&nbsp;and&nbsp;Bluetooth&nbsp;devices&nbsp;and&nbsp;therefore&nbsp;may&nbsp;fluctuate&nbsp;greatly.&nbsp;This&nbsp;policy&nbsp;is&nbsp;recommended&nbsp;and&nbsp;can&nbsp;reduce&nbsp;power&nbsp;consumption&nbsp;when&nbsp;your&nbsp;application&nbsp;does&nbsp;not&nbsp;require&nbsp;high&nbsp;location&nbsp;accuracy&nbsp;or&nbsp;when&nbsp;base&nbsp;stations,&nbsp;visible&nbsp;WLANs,&nbsp;and&nbsp;Bluetooth&nbsp;devices&nbsp;are&nbsp;densely&nbsp;distributed.<br/>To&nbsp;use&nbsp;this&nbsp;policy,&nbsp;you&nbsp;must&nbsp;declare&nbsp;at&nbsp;least&nbsp;the&nbsp;**ohos.permission.LOCATION**&nbsp;permission&nbsp;and&nbsp;obtain&nbsp;users'&nbsp;authorization. | | Power efficiency priority| LOW_POWER | This policy mainly uses the base station positioning, WLAN positioning, and Bluetooth positioning technologies to obtain device location in both indoor and outdoor scenarios. The location accuracy depends on the distribution of surrounding base stations, visible WLANs, and Bluetooth devices and therefore may fluctuate greatly. This policy is recommended and can reduce power consumption when your application does not require high location accuracy or when base stations, visible WLANs, and Bluetooth devices are densely distributed.<br>To use this policy, you must declare at least the **ohos.permission.LOCATION** permission and obtain users' authorization.|
The following example instantiates the **RequestParam** object for the location accuracy priority policy: Sample code for initializing **requestInfo** for the location accuracy priority policy:
``` ```
var requestInfo = {'priority': geolocation.LocationRequestPriority.ACCURACY, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0}; var requestInfo = {'priority': geolocation.LocationRequestPriority.ACCURACY, 'timeInterval': 0, 'distanceInterval': 0, 'maxAccuracy': 0};
``` ```
4. Instantiate the **Callback** object for the system to report location results. 4. Instantiate the **Callback** object for the system to report location results.
Your application needs to implement the callback interface defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic. Your application needs to implement the callback defined by the system. When the system successfully obtains the real-time location of a device, it will report the location result to your application through the callback interface. Your application can implement the callback interface in such a way to complete your own service logic.
``` ```
var locationChange = (location) => { var locationChange = (location) => {
...@@ -176,8 +177,8 @@ To learn more about the APIs for obtaining device location information, see [Geo ...@@ -176,8 +177,8 @@ To learn more about the APIs for obtaining device location information, see [Geo
geolocation.off('locationChange', locationChange); geolocation.off('locationChange', locationChange);
``` ```
If your application does not need the real-time device location, it can use the last known device location cached in the system instead. If your application does not need the real-time device location, it can use the last known device location cached in the system instead.
``` ```
geolocation.getLastLocation((err, data) => { geolocation.getLastLocation((err, data) => {
if (err) { if (err) {
......
...@@ -44,7 +44,7 @@ call.dial("138xxxxxxxx", (err, data) => { ...@@ -44,7 +44,7 @@ call.dial("138xxxxxxxx", (err, data) => {
dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean\>\): void dial\(phoneNumber: string, options: DialOptions, callback: AsyncCallback<boolean\>\): void
Initiates a call. You can set call options as needed. This API uses an asynchronous callback to return the result. Initiates a call based on the specified options. This API uses an asynchronous callback to return the result.
**Required permission**: ohos.permission.PLACE\_CALL (a system permission) **Required permission**: ohos.permission.PLACE\_CALL (a system permission)
...@@ -73,7 +73,7 @@ call.dial("138xxxxxxxx", { ...@@ -73,7 +73,7 @@ call.dial("138xxxxxxxx", {
dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\> dial\(phoneNumber: string, options?: DialOptions\): Promise<boolean\>
Initiates a call. You can set call options as needed. This API uses a promise to return the result. Initiates a call based on the specified options. This API uses a promise to return the result.
**Required permission**: ohos.permission.PLACE\_CALL (a system permission) **Required permission**: ohos.permission.PLACE\_CALL (a system permission)
...@@ -304,7 +304,7 @@ call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => { ...@@ -304,7 +304,7 @@ call.isEmergencyPhoneNumber("138xxxxxxxx", (err, data) => {
isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback<boolean\>\): void isEmergencyPhoneNumber\(phoneNumber: string, options: EmergencyNumberOptions, callback: AsyncCallback<boolean\>\): void
Checks whether the called number is an emergency number based on the phone number. This API uses an asynchronous callback to return the result. Checks whether the called number is an emergency number based on the specified phone number options. This API uses an asynchronous callback to return the result.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -313,7 +313,7 @@ Checks whether the called number is an emergency number based on the phone numbe ...@@ -313,7 +313,7 @@ Checks whether the called number is an emergency number based on the phone numbe
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------------------------------- | ---- | -------------------------------------------- | | ----------- | -------------------------------------------------- | ---- | -------------------------------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number option. | | options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number options. |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br> - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number. | | callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.<br> - **true**: The called number is an emergency number.<br>- **false**: The called number is not an emergency number. |
**Example** **Example**
...@@ -329,7 +329,7 @@ call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => { ...@@ -329,7 +329,7 @@ call.isEmergencyPhoneNumber("112", {slotId: 1}, (err, value) => {
isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise<boolean\> isEmergencyPhoneNumber\(phoneNumber: string, options?: EmergencyNumberOptions\): Promise<boolean\>
Checks whether the called number is an emergency number based on the phone number. This API uses a promise to return the result. Checks whether the called number is an emergency number based on the specified phone number options. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -338,7 +338,7 @@ Checks whether the called number is an emergency number based on the phone numbe ...@@ -338,7 +338,7 @@ Checks whether the called number is an emergency number based on the phone numbe
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------------------------------- | ---- | -------------- | | ----------- | -------------------------------------------------- | ---- | -------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number option. | | options | [EmergencyNumberOptions](#emergencynumberoptions7) | Yes | Phone number options. |
**Return value** **Return value**
...@@ -386,7 +386,7 @@ call.formatPhoneNumber("138xxxxxxxx", (err, data) => { ...@@ -386,7 +386,7 @@ call.formatPhoneNumber("138xxxxxxxx", (err, data) => {
formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback<string\>\): void formatPhoneNumber\(phoneNumber: string, options: NumberFormatOptions, callback: AsyncCallback<string\>\): void
Formats a phone number based on specified formatting options. This API uses an asynchronous callback to return the result. Formats a phone number based on the specified formatting options. This API uses an asynchronous callback to return the result.
A formatted phone number is a standard numeric string, for example, 555 0100. A formatted phone number is a standard numeric string, for example, 555 0100.
...@@ -397,7 +397,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. ...@@ -397,7 +397,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------------------------- | ---- | ------------------------------------ | | ----------- | -------------------------------------------- | ---- | ------------------------------------ |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting option, for example, country code. | | options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting options, for example, country code. |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -415,7 +415,7 @@ call.formatPhoneNumber("138xxxxxxxx",{ ...@@ -415,7 +415,7 @@ call.formatPhoneNumber("138xxxxxxxx",{
formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise<string\> formatPhoneNumber\(phoneNumber: string, options?: NumberFormatOptions\): Promise<string\>
Formats a phone number based on specified formatting options. This API uses a promise to return the result. Formats a phone number based on the specified formatting options. This API uses a promise to return the result.
A formatted phone number is a standard numeric string, for example, 555 0100. A formatted phone number is a standard numeric string, for example, 555 0100.
...@@ -426,7 +426,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100. ...@@ -426,7 +426,7 @@ A formatted phone number is a standard numeric string, for example, 555 0100.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | -------------------------------------------- | ---- | ---------------------- | | ----------- | -------------------------------------------- | ---- | ---------------------- |
| phoneNumber | string | Yes | Phone number. | | phoneNumber | string | Yes | Phone number. |
| options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting option, for example, country code. | | options | [NumberFormatOptions](#numberformatoptions7) | Yes | Number formatting options, for example, country code. |
**Return value** **Return value**
...@@ -514,15 +514,2242 @@ promise.then(data => { ...@@ -514,15 +514,2242 @@ promise.then(data => {
}); });
``` ```
## call.muteRinger<sup>8+</sup>
muteRinger\(callback: AsyncCallback<void\>\): void
Mutes the ringtone while it is playing. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.muteRinger((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.muteRinger<sup>8+</sup>
muteRinger\(\): Promise<void\>
Mutes the ringtone while it is playing. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.muteRinger();
promise.then(data => {
console.log(`muteRinger success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`muteRinger fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.answer<sup>7+</sup>
answer\(callback: AsyncCallback<void\>\): void
Answers a call. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.answer((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.answer<sup>7+</sup>
answer\(callId: number, callback: AsyncCallback<void\>\): void
Answers a call based on the specified call ID. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------------------------- |
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.answer(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.answer<sup>7+</sup>
answer(callId?: number\): Promise<void\>
Answers a call based on the specified call ID. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.ANSWER_CALL
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.answer(1);
promise.then(data => {
console.log(`answer success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`answer fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.hangup<sup>7+</sup>
hangup\(callback: AsyncCallback<void\>\): void
Ends a call. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.hangup((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.hangup<sup>7+</sup>
hangup\(callId: number, callback: AsyncCallback<void\>\): void
Ends a call based on the specified call ID. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------------------------- |
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.hangup(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.hangup<sup>7+</sup>
hangup\(callId?: number\): Promise<void\>
Ends a call based on the specified call ID. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ |
| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.hangup(1);
promise.then(data => {
console.log(`hangup success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`hangup fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.reject<sup>7+</sup>
reject\(callback: AsyncCallback<void\>\): void
Rejects a call. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.reject((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.reject<sup>7+</sup>
reject\(options: RejectMessageOptions, callback: AsyncCallback<void\>\): void
Rejects a call based on the specified options. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | -------------- |
| options | [RejectMessageOptions](#rejectmessageoptions7) | Yes | Options for the call rejection message.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
call.reject(rejectMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.reject<sup>7+</sup>
reject(callId: number, callback: AsyncCallback<void\>): <void\>
Rejects a call based on the specified call ID. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------------------------- |
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.reject(1);
promise.then(data => {
console.log(`reject success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`reject fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.reject<sup>7+</sup>
reject\(callId: number, options: RejectMessageOption, callback: AsyncCallback<void\>\): void
Rejects a call based on the specified call ID and options. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------- | ---- | ----------------------------------------------- |
| callId | number | Yes | Call ID. You can obtain the value by subscribing to **callDetailsChange** events.|
| options | [RejectMessageOptions](#rejectmessageoptions7) | Yes | Options for the call rejection message. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
call.reject(1, rejectMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.reject<sup>7+</sup>
reject(callId?: number, options?: RejectMessageOptions\): Promise<void\>
Rejects a call based on the specified call ID and options. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ---------------------------------------------- | ---- | ------------------------------------------------------------ |
| callId | number | No | Call ID. You can obtain the value by subscribing to **callDetailsChange** events. This parameter is optional from API version 9.|
| options | [RejectMessageOptions](#rejectmessageoptions7) | No | Options for the call rejection message. |
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let rejectMessageOptions={
messageContent: "Unknown number blocked"
}
let promise = call.reject(1, rejectMessageOptions);
promise.then(data => {
console.log(`reject success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`reject fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.holdCall<sup>7+</sup>
holdCall\(callId: number, callback: AsyncCallback<void\>\): void
Holds a call based on the specified call ID. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.holdCall(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.holdCall<sup>7+</sup>
holdCall\(callId: number\): Promise<void\>
Holds a call based on the specified call ID. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.holdCall(1);
promise.then(data => {
console.log(`holdCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`holdCall fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.unHoldCall<sup>7+</sup>
unHoldCall\(callId: number, callback: AsyncCallback<void\>\): void
Unholds a call based on the specified call ID. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.unHoldCall(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.unHoldCall<sup>7+</sup>
unHoldCall\(callId: number\): Promise<void\>
Unholds a call based on the specified call ID. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.unHoldCall(1);
promise.then(data => {
console.log(`unHoldCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`unHoldCall fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.switchCall<sup>7+</sup>
switchCall\(callId: number, callback: AsyncCallback<void\>\): void
Switches a call. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.switchCall(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.switchCall<sup>7+</sup>
switchCall\(callId: number\): Promise<void\>
Switches a call. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.switchCall(1);
promise.then(data => {
console.log(`switchCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`switchCall fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.combineConference<sup>7+</sup>
combineConference\(callId: number, callback: AsyncCallback<void\>\): void
Combines two calls into a conference call. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.combineConference(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.combineConference<sup>7+</sup>
combineConference\(callId: number\): Promise<void\>
Combines two calls into a conference call. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.combineConference(1);
promise.then(data => {
console.log(`combineConference success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`combineConference fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.getMainCallId<sup>7+</sup>
getMainCallId\(callId: number, callback: AsyncCallback<number\>\): void
Obtains the main call ID. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ------------------------ |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback&lt;number&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.getMainCallId(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.getMainCallId<sup>7+</sup>
getMainCallId\(callId: number\): Promise<number\>
Obtains the main call ID. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.getMainCallId(1);
promise.then(data => {
console.log(`getMainCallId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getMainCallId fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.getSubCallIdList<sup>7+</sup>
getSubCallIdList\(callId: number, callback: AsyncCallback<Array<string\>\>\): void
Obtains the list of subcall IDs. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------ | ---- | ---------------------------- |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback<Array<string\>\> | Yes | Callback used to return the result. |
**Example**
```js
call.getSubCallIdList(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.getSubCallIdList<sup>7+</sup>
getSubCallIdList\(callId: number\): Promise<Array<string\>\>
Obtains the list of subcall IDs. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ----------------------------- | ----------------------------------- |
| Promise&lt;Array<string\>&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.getSubCallIdList(1);
promise.then(data => {
console.log(`getSubCallIdList success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getSubCallIdList fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.getCallIdListForConference<sup>7+</sup>
getCallIdListForConference\(callId: number, callback: AsyncCallback<Array<string\>>\): void
Obtains the list of call IDs in a conference. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | -------------------------------- |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback&lt;Array<string\>&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.getCallIdListForConference(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.getCallIdListForConference<sup>7+</sup>
getCallIdListForConference\(callId: number\): Promise<Array<string\>\>
Obtains the list of call IDs in a conference. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ----------------------------- | --------------------------------------- |
| Promise&lt;Array<string\>&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.getCallIdListForConference(1);
promise.then(data => {
console.log(`getCallIdListForConference success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getCallIdListForConference fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.getCallWaitingStatus<sup>7+</sup>
getCallWaitingStatus\(slotId: number, callback: AsyncCallback<CallWaitingStatus\>\): void
Obtains the call waiting status. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | AsyncCallback&lt;[CallWaitingStatus](#callwaitingstatus7)\> | Yes | Callback used to return the result.<br> <br>- **0**: Call waiting is disabled.<br>- **1**: Call waiting is enabled.|
**Example**
```js
call.getCallWaitingStatus(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.getCallWaitingStatus<sup>7+</sup>
getCallWaitingStatus\(slotId: number\): Promise<CallWaitingStatus\>
Obtains the call waiting status. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ------------------------------------------------------- | ------------------------------------------------------------ |
| Promise&lt;[CallWaitingStatus](#callwaitingstatus7)&gt; | Promise used to return the result.<br>- **0**: Call waiting is disabled.<br>- **1**: Call waiting is enabled.|
**Example**
```js
let promise = call.getCallWaitingStatus(0);
promise.then(data => {
console.log(`getCallWaitingStatus success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getCallWaitingStatus fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.setCallWaiting<sup>7+</sup>
setCallWaiting\(slotId: number, activate: boolean, callback: AsyncCallback<void\>\): void
Sets the call waiting switch. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| activate | boolean | Yes | Whether to enable call waiting.<br>- **false**: Disable call waiting.<br>- **true**: Enable call waiting.|
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
**Example**
```js
call.setCallWaiting(0, true, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.setCallWaiting<sup>7+</sup>
setCallWaiting\(slotId: number, activate: boolean\): Promise<void\>
Sets the call waiting switch. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| activate | boolean | Yes | Whether to enable call waiting.<br>- **false**: Disable call waiting.<br>- **true**: Enable call waiting.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.setCallWaiting(0, true);
promise.then(data => {
console.log(`setCallWaiting success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`setCallWaiting fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.startDTMF<sup>7+</sup>
startDTMF\(callId: number, character: string, callback: AsyncCallback<void\>\): void
Enables dual-tone multifrequency (DTMF). This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | -------------------- | ---- | ---------- |
| callId | number | Yes | Call ID. |
| character | string | Yes | DTMF code. |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result.|
**Example**
```js
call.startDTMF(1, "0", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.startDTMF<sup>7+</sup>
startDTMF\(callId: number, character: string\): Promise<void\>
Enables DTMF. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
| character | string | Yes | DTMF code.|
**Return value**
| Type | Description |
| ------------------- | ----------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.startDTMF(1, "0");
promise.then(data => {
console.log(`startDTMF success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`startDTMF fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.stopDTMF<sup>7+</sup>
stopDTMF\(callId: number, callback: AsyncCallback<void\>\): void
Stops DTMF. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.stopDTMF(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.stopDTMF<sup>7+</sup>
stopDTMF\(callId: number\): Promise<void\>
Stops DTMF. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.stopDTMF(1);
promise.then(data => {
console.log(`stopDTMF success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`stopDTMF fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.isInEmergencyCall<sup>7+</sup>
isInEmergencyCall\(callback: AsyncCallback<boolean\>\): void
Checks whether a call is an emergency call. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.isInEmergencyCall((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.isInEmergencyCall<sup>7+</sup>
isInEmergencyCall\(\): Promise<boolean\>
Checks whether a call is an emergency call. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Return value**
| Type | Description |
| ---------------------- | --------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.isInEmergencyCall();
promise.then(data => {
console.log(`isInEmergencyCall success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`isInEmergencyCall fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.on('callDetailsChange')<sup>7+</sup>
on\(type: 'callDetailsChange', callback: Callback<CallAttributeOptions\>\): void
Subscribes to **callDetailsChange** events. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------- | ---- | -------------------------- |
| type | string | Yes | Call details change during a call.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | Yes | Callback used to return the result. |
**Example**
```js
call.on('callDetailsChange', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.on('callEventChange')<sup>8+</sup>
on\(type: 'callEventChange', callback: Callback<CallEventOptions\>\): void
Subscribes to **callEventChange** events. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | -------------------------- |
| type | string | Yes | Call event change during a call.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | Yes | Callback used to return the result. |
**Example**
```js
call.on('callEventChange', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.on('callDisconnectedCause')<sup>8+</sup>
on\(type: 'callDisconnectedCause', callback: Callback<DisconnectedDetails\>): void
Subscribes to **callDisconnectedCause** events. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------ | ---- | -------------------------- |
| type | string | Yes | Cause of the call disconnection.|
| callback | Callback<[DisconnectedDetails](#disconnecteddetails8)> | Yes | Callback used to return the result. |
**Example**
```js
call.on('callDisconnectedCause', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.on('mmiCodeResult')<sup>9+</sup>
on\(type: 'mmiCodeResult', callback: Callback<MmiCodeResults\>\): void
Subscribes to **mmiCodeResult** events. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | --------------------- |
| type | string | Yes | Man-machine interface (MMI) code result.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | Yes | Callback used to return the result. |
**Example**
```js
isNewCallAllowedcall.on('mmiCodeResult', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.off('callDetailsChange')<sup>7+</sup>
off\(type: 'callDetailsChange', callback?: Callback<CallAttributeOptions\>\): void
Unsubscribes from **callDetailsChange** events. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------------------- | ---- | ---------------------------------- |
| type | string | Yes | Unsubscription from call details changes when a call ends.|
| callback | Callback<[CallAttributeOptions](#callattributeoptions7)> | No | Callback used to return the result. |
**Example**
```js
call.off('callDetailsChange', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.off('callEventChange')<sup>8+</sup>
off\(type: 'callEventChange', callback?: Callback<CallEventOptions\>\): void
Unsubscribes from **callEventChange** events. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ---------------------------------- |
| type | string | Yes | Unsubscription from call event changes when a call ends.|
| callback | Callback<[CallEventOptions](#calleventoptions8)> | No | Callback used to return the result. |
**Example**
```js
call.off('callEventChange', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.off('callDisconnectedCause')<sup>8+</sup>
off\(type: 'callDisconnectedCause', callback?: Callback<DisconnectedDetails\>\): void
Unsubscribes from **callDisconnectedCause** events. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------------- | ---- | -------------------- |
| type | 'callDisconnectedCause' | Yes | Unsubscription from the call disconnection cause when a call ends.|
| callback | Callback**<**[DisconnectedDetails](#disconnecteddetails8)> | No | Callback used to return the result. |
**Example**
```js
call.off('callDisconnectedCause', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.off('mmiCodeResult')<sup>9+</sup>
off\(type: 'mmiCodeResult', callback?: Callback<MmiCodeResults\>\): void
Unsubscribes from **mmiCodeResult** events. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------ | ---- | ----------- |
| type | 'mmiCodeResult' | Yes | MMI code result.|
| callback | Callback<[MmiCodeResults](#mmicoderesults9)> | No | Callback used to return the result. |
**Example**
```js
call.off('mmiCodeResult', (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.isNewCallAllowed<sup>8+</sup>
isNewCallAllowed\(callback: AsyncCallback<boolean\>\): void
Checks whether a new call is allowed. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.isNewCallAllowed((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.isNewCallAllowed<sup>8+</sup>
isNewCallAllowed\(\): Promise<boolean\>
Checks whether a new call is allowed. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Return value**
| Type | Description |
| ---------------------- | --------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.isNewCallAllowed();
promise.then(data => {
console.log(`isNewCallAllowed success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`isNewCallAllowed fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.separateConference<sup>8+</sup>
separateConference\(callId: number, callback: AsyncCallback<void\>\): void
Separates a conference call. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callId | number | Yes | Call ID. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.separateConference(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.separateConference<sup>8+</sup>
separateConference\(callId: number\): Promise<void\>
Separates a conference call. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------- |
| callId | number | Yes | Call ID.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.separateConference(1);
promise.then(data => {
console.log(`separateConference success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`separateConference fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.getCallRestrictionStatus<sup>8+</sup>
getCallRestrictionStatus\(slotId: number, type: CallRestrictionType, callback: AsyncCallback<RestrictionStatus\>\): void
Obtains the call restriction status. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| type | [CallRestrictionType](#callrestrictiontype8) | Yes | Call restriction type. |
| callback | AsyncCallback&lt;[RestrictionStatus](#restrictionstatus8)&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.getCallRestrictionStatus(0, 1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.getCallRestrictionStatus<sup>8+</sup>
getCallRestrictionStatus\(slotId: number, type: CallRestrictionType\): Promise<RestrictionStatus\>
Obtains the call restriction status. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| type | [CallRestrictionType](#callrestrictiontype8) | Yes | Call restriction type. |
**Return value**
| Type | Description |
| ------------------------------------------------------- | --------------------------- |
| Promise&lt;[RestrictionStatus](#restrictionstatus8)&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.getCallRestrictionStatus(0, 1);
promise.then(data => {
console.log(`getCallRestrictionStatus success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getCallRestrictionStatus fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.setCallRestriction<sup>8+</sup>
setCallRestriction\(slotId: number, info: CallRestrictionInfo, callback: AsyncCallback<void\>\): void
Sets the call restriction status. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| info | [CallRestrictionInfo](#callrestrictioninfo8) | Yes | Call restriction information. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let callRestrictionInfo={
type: 1,
password: "123456",
mode: 1
}
call.setCallRestriction(0, callRestrictionInfo, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.setCallRestriction<sup>8+</sup>
setCallRestriction\(slotId: number, info: CallRestrictionInfo\): Promise<void\>
Sets the call restriction status. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| info | [CallRestrictionInfo](#callrestrictioninfo8) | Yes | Call restriction information. |
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let callRestrictionInfo={
type: 1,
password: "123456",
mode: 1
}
let promise = call.setCallRestriction(0, callRestrictionInfo);
promise.then(data => {
console.log(`setCallRestriction success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`setCallRestriction fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.getCallTransferInfo<sup>8+</sup>
getCallTransferInfo\(slotId: number, type: CallTransferType, callback: AsyncCallback<CallTransferResult\>\): void
Obtains call transfer information. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| type | [CallTransferType](#calltransfertype8) | Yes | Call transfer type. |
| callback | AsyncCallback&lt;[CallTransferResult](#calltransferresult8)&gt; | Yes | Callback used to return the result. |
**Example**
```js
let callTransferTyp={
CallTransferType: 1
}
call.getCallTransferInfo(0, callTransferTyp, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.getCallTransferInfo<sup>8+</sup>
getCallTransferInfo\(slotId: number, type: CallTransferType): Promise<CallTransferResult\>
Obtains call transfer information. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| type | [CallTransferType](#calltransfertype8) | Yes | Call transfer type. |
**Return value**
| Type | Description |
| --------------------------------------------------------- | --------------------------- |
| Promise&lt;[CallTransferResult](#calltransferresult8)&gt; | Promise used to return the result.|
**Example**
```js
let callTransferTyp={
CallTransferType: 1
}
let promise = call.getCallTransferInfo(0, callTransferTyp);
promise.then(data => {
console.log(`getCallTransferInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getCallTransferInfo fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.setCallTransfer<sup>8+</sup>
setCallTransfer\(slotId: number, info: CallTransferInfo, callback: AsyncCallback<void\>\): void
Sets call transfer information. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| info | [CallTransferInfo](#calltransferinfo8) | Yes | Call transfer information. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let callTransferInfo={
transferNum: "111",
type: 1,
settingType: 1
}
call.setCallTransfer(0, callTransferInfo, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.setCallTransfer<sup>8+</sup>
setCallTransfer\(slotId: number, info: CallTransferInfo): Promise<void\>
Sets call transfer information. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| info | [CallTransferInfo](#calltransferinfo8) | Yes | Call transfer information. |
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let callTransferInfo={
transferNum: "111",
type: 1,
settingType: 1
}
let promise = call.setCallTransfer(0, callTransferInfo);
promise.then(data => {
console.log(`setCallTransfer success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`setCallTransfer fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.isRinging<sup>8+</sup>
isRinging\(callback: AsyncCallback<boolean\>\): void
Checks whether the ringtone is playing. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.isRinging((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.isRinging<sup>8+</sup>
isRinging\(\): Promise<boolean\>
Checks whether the ringtone is playing. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CallManager
**Return value**
| Type | Description |
| ---------------------- | --------------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.isRinging();
promise.then(data => {
console.log(`isRinging success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`isRinging fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.setMuted<sup>8+</sup>
setMuted\(callback: AsyncCallback<void\>\): void
Sets call muting. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.setMuted((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.setMuted<sup>8+</sup>
setMuted\(\): Promise<void\>
Sets call muting. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.setMuted();
promise.then(data => {
console.log(`setMuted success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`setMuted fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.cancelMuted<sup>8+</sup>
cancelMuted(callback: AsyncCallback<void\>): void
Cancels call muting. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.cancelMuted((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.cancelMuted<sup>8+</sup>
cancelMuted(): Promise<void\>
Cancels call muting. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.cancelMuted();
promise.then(data => {
console.log(`cancelMuted success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`cancelMuted fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.setAudioDevice<sup>8+</sup>
setAudioDevice\(device: AudioDevice, callback: AsyncCallback<void\>\): void
Sets the audio device for a call. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------- |
| device | [AudioDevice](#audiodevice8) | Yes | Audio device.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result.|
**Example**
```js
call.setAudioDevice(1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.setAudioDevice<sup>8+</sup>
setAudioDevice\(device: AudioDevice, options: AudioDeviceOptions, callback: AsyncCallback<void\>\): void
Sets the audio device for a call based on the specified options. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------ | ---- | -------------- |
| device | [AudioDevice](#audiodevice8) | Yes | Audio device. |
| options | [AudioDeviceOptions](#audiodeviceoptions9) | Yes | Audio device parameters.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014"
}
call.setAudioDevice(1, bluetoothAddress, (err, value) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.setAudioDevice<sup>8+</sup>
setAudioDevice(device: AudioDevice, options?: AudioDeviceOptions): Promise<void\>
Sets the audio device for a call based on the specified options. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------ | ---- | ------------------ |
| device | [AudioDevice](#audiodevice8) | Yes | Audio device. |
| options | [AudioDeviceOptions](#audiodeviceoptions9) | No | Audio device parameters.|
**Return value**
| Type | Description |
| ------------------- | ------------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let audioDeviceOptions={
bluetoothAddress: "IEEE 802-2014"
}
let promise = call.setAudioDevice(1, audioDeviceOptions);
promise.then(data => {
console.log(`setAudioDevice success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`setAudioDevice fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.joinConference<sup>8+</sup>
joinConference(mainCallId: number, callNumberList: Array<string\>, callback: AsyncCallback<void\>): void
Joins a conference call. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | ------------------------- | ---- | --------------- |
| mainCallId | number | Yes | Main call ID. |
| callNumberList | Array<string\> | Yes | List of call numbers.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.joinConference(1, "138XXXXXXXX", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.joinConference<sup>8+</sup>
joinConference(mainCallId: number, callNumberList: Array<string\>): Promise<void\>
Joins a conference call. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------------- | -------------- | ---- | --------------- |
| mainCallId | number | Yes | Main call ID. |
| callNumberList | Array<string\> | Yes | List of call numbers.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.joinConference(1, "138XXXXXXXX");
promise.then(data => {
console.log(`joinConference success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`joinConference fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.updateImsCallMode<sup>8+</sup>
updateImsCallMode(callId: number, mode: ImsCallMode, callback: AsyncCallback<void\>): void
Updates the IMS call mode. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | -------------- |
| callId | number | Yes | Call ID. |
| mode | [ImsCallMode](#imscallmode8) | Yes | IMS call mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.updateImsCallMode(1, 1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.updateImsCallMode<sup>8+</sup>
updateImsCallMode(callId: number, mode: ImsCallMode): Promise<void\>
Updates the IMS call mode. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------------------------- | ---- | -------------- |
| callId | number | Yes | Call ID. |
| mode | [ImsCallMode](#imscallmode8) | Yes | IMS call mode.|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.updateImsCallMode(1, 1);
promise.then(data => {
console.log(`updateImsCallMode success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`updateImsCallMode fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.enableImsSwitch<sup>8+</sup>
enableImsSwitch(slotId: number, callback: AsyncCallback<void\>): void
Enables the IMS switch. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.enableImsSwitch(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.enableImsSwitch<sup>8+</sup>
enableImsSwitch(slotId: number): Promise<void\>
Enables the IMS switch. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.enableImsSwitch(0);
promise.then(data => {
console.log(`enableImsSwitch success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`enableImsSwitch fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.disableImsSwitch<sup>8+</sup>
disableImsSwitch(slotId: number, callback: AsyncCallback<void\>): void
Disables the IMS switch. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.disableImsSwitch(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.disableImsSwitch<sup>8+</sup>
disableImsSwitch(slotId: number): Promise<void\>
Disables the IMS switch. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.disableImsSwitch(0);
promise.then(data => {
console.log(`disableImsSwitch success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`disableImsSwitch fail, promise: err->${JSON.stringify(err)}`);
});
```
## call.isImsSwitchEnabled<sup>8+</sup>
isImsSwitchEnabled(slotId: number, callback: AsyncCallback<boolean\>): void
Checks whether the IMS switch is enabled. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result. |
**Example**
```js
call.isImsSwitchEnabled(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## call.isImsSwitchEnabled<sup>8+</sup>
isImsSwitchEnabled(slotId: number): Promise<boolean\>
Checks whether the IMS switch is enabled. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ------------------- | --------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let promise = call.isImsSwitchEnabled(0);
promise.then(data => {
console.log(`isImsSwitchEnabled success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`isImsSwitchEnabled fail, promise: err->${JSON.stringify(err)}`);
});
```
## DialOptions ## DialOptions
Provides an option for determining whether a call is a video call. Defines the dialup options.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Name| Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------ | ------- | ---- | ------------------------------------------------------------ | | ---------- | ---------------------------------- | ---- | ------------------------------------------------------------ |
| extras | boolean | No | Indication of a video call. <br>- **true**: video call<br>- **false** (default): voice call| | extras | boolean | No | Indication of a video call. <br>- **true**: video call<br>- **false** (default): voice call|
| accountId | number | No | Account ID. This API is supported since API version 8. It is a system API. |
| videoState | [VideoStateType](#videostatetype7) | No | Video state type. This API is supported since API version 8. It is a system API. |
| dialScene | [DialScene](#dialscene8) | No | Dialup scenario. This API is supported since API version 8. It is a system API. |
| dialType | [DialType](#dialtype8) | No | Dialup type. This API is supported since API version 8. It is a system API. |
## CallState ## CallState
...@@ -539,7 +2766,7 @@ Enumerates call states. ...@@ -539,7 +2766,7 @@ Enumerates call states.
## EmergencyNumberOptions<sup>7+</sup> ## EmergencyNumberOptions<sup>7+</sup>
Provides an option for determining whether a number is an emergency number for the SIM card in the specified slot. Defines options for determining whether a number is an emergency number.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
...@@ -549,10 +2776,401 @@ Provides an option for determining whether a number is an emergency number for t ...@@ -549,10 +2776,401 @@ Provides an option for determining whether a number is an emergency number for t
## NumberFormatOptions<sup>7+</sup> ## NumberFormatOptions<sup>7+</sup>
Provides an option for number formatting. Defines the number formatting options.
**System capability**: SystemCapability.Telephony.CallManager **System capability**: SystemCapability.Telephony.CallManager
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ----------- | ------ | ---- | ---------------------------------------------------------- | | ----------- | ------ | ---- | ---------------------------------------------------------- |
| countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**. | | countryCode | string | No | Country code, for example, **CN** (China). All country codes are supported. The default value is **CN**. |
## ImsCallMode<sup>8+</sup>
Enumerates IMS call modes.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ---------------------- | ---- | ------------------ |
| CALL_MODE_AUDIO_ONLY | 0 | Audio call only. |
| CALL_MODE_SEND_ONLY | 1 | Sending calls only. |
| CALL_MODE_RECEIVE_ONLY | 2 | Receiving calls only. |
| CALL_MODE_SEND_RECEIVE | 3 | Sending and receiving calls.|
| CALL_MODE_VIDEO_PAUSED | 4 | Pausing video calls. |
## AudioDevice<sup>8+</sup>
Enumerates audio devices.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| -------------------- | ---- | ------------ |
| DEVICE_EARPIECE | 0 | Headset device. |
| DEVICE_SPEAKER | 1 | Speaker device.|
| DEVICE_WIRED_HEADSET | 2 | Wired headset device.|
| DEVICE_BLUETOOTH_SCO | 3 | Bluetooth SCO device. |
## CallRestrictionType<sup>8+</sup>
Enumerates call restriction types.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| --------------------------------------------- | ---- | -------------------------- |
| RESTRICTION_TYPE_ALL_INCOMING | 0 | Barring of all incoming calls. |
| RESTRICTION_TYPE_ALL_OUTGOING | 1 | Barring of all outgoing calls. |
| RESTRICTION_TYPE_INTERNATIONAL | 2 | Barring of international calls. |
| RESTRICTION_TYPE_INTERNATIONAL_EXCLUDING_HOME | 3 | Barring of international calls except those in the home country.|
| RESTRICTION_TYPE_ROAMING_INCOMING | 4 | Barring of incoming roaming calls. |
| RESTRICTION_TYPE_ALL_CALLS | 5 | Barring of all calls. |
| RESTRICTION_TYPE_OUTGOING_SERVICES | 6 | Barring of outgoing services. |
| RESTRICTION_TYPE_INCOMING_SERVICES | 7 | Barring of incoming services. |
## CallTransferInfo<sup>8+</sup>
Defines the call transfer information.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------------------------------- | ---- | ---------------- |
| transferNum | string | Yes | Call transfer number. |
| type | [CallTransferType](#calltransfertype8) | Yes | Call transfer type. |
| settingType | [CallTransferSettingType](#calltransfersettingtype8) | Yes | Call transfer setting type.|
## CallTransferType<sup>8+</sup>
Enumerates call transfer types.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| --------------------------- | ---- | ------------ |
| TRANSFER_TYPE_UNCONDITIONAL | 0 | Call forwarding unconditional. |
| TRANSFER_TYPE_BUSY | 1 | Call forwarding busy. |
| TRANSFER_TYPE_NO_REPLY | 2 | Call forwarding on no reply. |
| TRANSFER_TYPE_NOT_REACHABLE | 3 | Call forwarding on no user not reachable.|
## CallTransferSettingType<sup>8+</sup>
Enumerates call transfer setting types.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| -------------------------- | ---- | ------------ |
| CALL_TRANSFER_DISABLE | 0 | Disabling of call transfer.|
| CALL_TRANSFER_ENABLE | 1 | Enabling of call transfer.|
| CALL_TRANSFER_REGISTRATION | 3 | Registration of call transfer.|
| CALL_TRANSFER_ERASURE | 4 | Erasing of call transfer.|
## CallAttributeOptions<sup>7+</sup>
Defines the call attribute options.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Type | Mandatory| Description |
| --------------- | ---------------------------------------- | ---- | -------------- |
| accountNumber | string | Yes | Account number. |
| speakerphoneOn | boolean | Yes | Speakerphone on.|
| accountId | number | Yes | Account ID. |
| videoState | [VideoStateType](#videostatetype7) | Yes | Video state type. |
| startTime | number | Yes | Start time. |
| isEcc | boolean | Yes | Whether the call is an ECC. |
| callType | [CallType](#calltype7) | Yes | Call type. |
| callId | number | Yes | Call ID. |
| callState | [DetailedCallState](#detailedcallstate7) | Yes | Detailed call state. |
| conferenceState | [ConferenceState](#conferencestate7) | Yes | Conference state. |
## ConferenceState<sup>7+</sup>
Enumerates conference states.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ---------------------------- | ---- | -------------- |
| TEL_CONFERENCE_IDLE | 0 | Idle state. |
| TEL_CONFERENCE_ACTIVE | 1 | Active state. |
| TEL_CONFERENCE_DISCONNECTING | 2 | Disconnecting state. |
| TEL_CONFERENCE_DISCONNECTED | 3 | Disconnected state.|
## CallType<sup>7+</sup>
Enumerates call types.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ------------- | ---- | ------------ |
| TYPE_CS | 0 | CS call. |
| TYPE_IMS | 1 | IMS call. |
| TYPE_OTT | 2 | OTT call. |
| TYPE_ERR_CALL | 3 | Error call type.|
## VideoStateType<sup>7+</sup>
Enumerates video state types.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ---------- | ---- | -------- |
| TYPE_VOICE | 0 | Voice state.|
| TYPE_VIDEO | 1 | Video state.|
## DetailedCallState<sup>7+</sup>
Enumerates detailed call states.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ------------------------- | ---- | -------------- |
| CALL_STATUS_ACTIVE | 0 | Active state. |
| CALL_STATUS_HOLDING | 1 | Hold state. |
| CALL_STATUS_DIALING | 2 | Dialing state. |
| CALL_STATUS_ALERTING | 3 | Alerting state. |
| CALL_STATUS_INCOMING | 4 | Incoming state. |
| CALL_STATUS_WAITING | 5 | Waiting state. |
| CALL_STATUS_DISCONNECTED | 6 | Disconnected state.|
| CALL_STATUS_DISCONNECTING | 7 | Disconnecting state. |
| CALL_STATUS_IDLE | 8 | Idle state. |
## CallRestrictionInfo<sup>8+</sup>
Defines the call restriction information.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Type | Mandatory| Description |
| -------- | -------------------------------------------- | ---- | ------------ |
| type | [CallRestrictionType](#callrestrictiontype8) | Yes | Call restriction type.|
| password | string | Yes | Password. |
| mode | [CallRestrictionMode](#callrestrictionmode8) | Yes | Call restriction mode.|
## CallRestrictionMode<sup>8+</sup>
Enumerates call restriction modes.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ----------------------------- | ---- | ------------ |
| RESTRICTION_MODE_DEACTIVATION | 0 | Call restriction deactivated.|
| RESTRICTION_MODE_ACTIVATION | 1 | Call restriction activated.|
## CallEventOptions<sup>8+</sup>
Defines the call event options.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------------ | ---- | -------------- |
| eventId | [CallAbilityEventId](#callabilityeventid8) | Yes | Call ability event ID.|
## CallAbilityEventId<sup>8+</sup>
Enumerates call ability event IDs.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ------------------------ | ---- | --------------- |
| EVENT_DIAL_NO_CARRIER | 1 | No available carrier during dialing. |
| EVENT_INVALID_FDN_NUMBER | 2 | Invalid FDN.|
## DialScene<sup>8+</sup>
Enumerates dialup scenarios.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| --------------- | ---- | ------------ |
| CALL_NORMAL | 0 | Common call. |
| CALL_PRIVILEGED | 1 | Privileged call. |
| CALL_EMERGENCY | 2 | Emergency call.|
## DialType<sup>8+</sup>
Enumerates dialup types.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| -------------------- | ---- | ---------------- |
| DIAL_CARRIER_TYPE | 0 | Carrier. |
| DIAL_VOICE_MAIL_TYPE | 1 | Voice mail.|
| DIAL_OTT_TYPE | 2 | OTT. |
## RejectMessageOptions<sup>7+</sup>
Defines options for the call rejection message.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Type | Mandatory| Description |
| -------------- | ------ | ---- | -------- |
| messageContent | string | Yes | Message content.|
## CallTransferResult<sup>8+</sup>
Defines the call transfer result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------- | ---- | -------- |
| status | [TransferStatus](#transferstatus8) | Yes | Transfer status.|
| number | string | Yes | Number. |
## CallWaitingStatus<sup>7+</sup>
Enumerates call waiting states.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| -------------------- | ---- | ------------ |
| CALL_WAITING_DISABLE | 0 | Call waiting disabled.|
| CALL_WAITING_ENABLE | 1 | Call waiting enabled.|
## RestrictionStatus<sup>8+</sup>
Enumerates call restriction states.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ------------------- | ---- | -------- |
| RESTRICTION_DISABLE | 0 | Call restriction disabled.|
| RESTRICTION_ENABLE | 1 | Call restriction enabled.|
## TransferStatus<sup>8+</sup>
Enumerates call transfer states.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ---------------- | ---- | -------- |
| TRANSFER_DISABLE | 0 | Call transfer disabled.|
| TRANSFER_ENABLE | 1 | Call transfer enabled.|
## DisconnectedDetails<sup>8+</sup>
Enumerates causes of call disconnection.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| --------------------------- | ---- | ---------------------- |
| UNASSIGNED_NUMBER | 1 | Unallocated number. |
| NO_ROUTE_TO_DESTINATION | 3 | No route to the destination. |
| CHANNEL_UNACCEPTABLE | 6 | Unacceptable channel. |
| OPERATOR_DETERMINED_BARRING | 8 | Operator determined barring (ODB). |
| NORMAL_CALL_CLEARING | 16 | Normal call clearing. |
| USER_BUSY | 17 | User busy. |
| NO_USER_RESPONDING | 18 | No user response. |
| USER_ALERTING_NO_ANSWER | 19 | Alerting but no answer.|
| CALL_REJECTED | 21 | Call rejected. |
| NUMBER_CHANGED | 22 | Number changed. |
| DESTINATION_OUT_OF_ORDER | 27 | Destination fault. |
| INVALID_NUMBER_FORMAT | 28 | Invalid number format. |
| NETWORK_OUT_OF_ORDER | 38 | Network fault. |
| TEMPORARY_FAILURE | 41 | Temporary fault. |
| INVALID_PARAMETER | 1025 | Invalid parameter. |
| SIM_NOT_EXIT | 1026 | SIM card not exit. |
| SIM_PIN_NEED | 1027 | SIM card PIN required. |
| CALL_NOT_ALLOW | 1029 | Call not allowed. |
| SIM_INVALID | 1045 | Invalid SIM card. |
| UNKNOWN | 1279 | Unknown reason. |
## MmiCodeResults<sup>9+</sup>
Defines the MMI code result.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Type | Mandatory| Description |
| ------- | -------------------------------- | ---- | --------------- |
| result | [MmiCodeResult](#mmicoderesult9) | Yes | MMI code result.|
| message | string | Yes | MMI code message.|
## MmiCodeResult<sup>9+</sup>
Enumerates MMI code results.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Value | Description |
| ---------------- | ---- | ------------- |
| MMI_CODE_SUCCESS | 0 | Success.|
| MMI_CODE_FAILED | 1 | Failure.|
## AudioDeviceOptions<sup>9+</sup>
Defines audio device options.
This is a system API.
**System capability**: SystemCapability.Telephony.CallManager
| Name | Type | Mandatory| Description |
| ---------------- | ------ | ---- | -------- |
| bluetoothAddress | string | No | Bluetooth address.|
...@@ -899,9 +899,698 @@ promise.then(data => { ...@@ -899,9 +899,698 @@ promise.then(data => {
}); });
``` ```
## radio.sendUpdateCellLocationRequest<sup>8+</sup>
sendUpdateCellLocationRequest\(callback: AsyncCallback<void\>\): void
Sends a cell location update request. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------- |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
```js
radio.sendUpdateCellLocationRequest((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.sendUpdateCellLocationRequest<sup>8+</sup>
sendUpdateCellLocationRequest\(\): Promise<void\>
Sends a cell location update request. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Return value**
| Type | Description |
| --------------- | ----------------------- |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let promise = radio.sendUpdateCellLocationRequest();
promise.then(data => {
console.log(`sendUpdateCellLocationRequest success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`sendUpdateCellLocationRequest fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.getCellInformation<sup>8+</sup>
getCellInformation(callback: AsyncCallback<Array<CellInformation\>>): void
Obtains cell information. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ------------------------ |
| callback | AsyncCallback\<Array<[CellInformation](#cellinformation8)\>\> | Yes | Callback used to return the result.|
**Example**
```js
radio.getCellInformation((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getCellInformation<sup>8+</sup>
getCellInformation(slotId: number, callback: AsyncCallback<Array<CellInformation\>\>): void
Obtains cell information. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<Array<[CellInformation](#cellinformation8)\>\> | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
radio.getCellInformation(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getCellInformation<sup>8+</sup>
getCellInformation(slotId?: number): Promise<Array<CellInformation\>\>
Obtains cell information. This API uses a promise to return the result.
This is a system API.
**Required permissions**: ohos.permission.LOCATION
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ------------------------------------------------------- | ----------------------- |
| Promise\<Array<[CellInformation](#cellinformation8)\>\> | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let promise = radio.getCellInformation(slotId);
promise.then(data => {
console.log(`getCellInformation success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getCellInformation fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.setNetworkSelectionMode
setNetworkSelectionMode\(options: NetworkSelectionModeOptions, callback: AsyncCallback<void\>\): void
Sets the network selection mode. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------ |
| options | [NetworkSelectionModeOptions](#networkselectionmodeoptions) | Yes | Network selection mode.|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example**
```js
let networkInformation={
operatorName: "China Mobile",
operatorNumeric: "898600",
state: 1,
radioTech: "CS"
}
let networkSelectionModeOptions={
slotid: 0,
selectMode: 1,
networkInformation: networkInformation,
resumeSelection: true
}
radio.setNetworkSelectionMode(networkSelectionModeOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.setNetworkSelectionMode
setNetworkSelectionMode\(options: NetworkSelectionModeOptions\): Promise<void\>
Sets the network selection mode. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ----------------------------------------------------------- | ---- | ------------------ |
| options | [NetworkSelectionModeOptions](#networkselectionmodeoptions) | Yes | Network selection mode.|
**Return value**
| Type | Description |
| --------------- | ----------------------- |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let networkInformation={
operatorName: "China Mobile",
operatorNumeric: "898600",
state: 1,
radioTech: "CS"
}
let networkSelectionModeOptions={
slotid: 0,
selectMode: 1,
networkInformation: networkInformation,
resumeSelection: true
}
let promise = radio.setNetworkSelectionMode(networkSelectionModeOptions);
promise.then(data => {
console.log(`setNetworkSelectionMode success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`setNetworkSelectionMode fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.getNetworkSearchInformation
getNetworkSearchInformation\(slotId: number, callback: AsyncCallback<NetworkSearchResult\>\): void
Obtains network search information. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[NetworkSearchResult](#networksearchresult)\> | Yes | Callback used to return the result. |
**Example**
```js
radio.getNetworkSearchInformation(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getNetworkSearchInformation
getNetworkSearchInformation\(slotId: number\): Promise<void\>
Obtains network search information. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ------------------------------------------------------ | ----------------------- |
| Promise\<[NetworkSearchResult](#networksearchresult)\> | Promise used to return the result.|
**Example**
```js
let promise = radio.getNetworkSearchInformation(0);
promise.then(data => {
console.log(`getNetworkSearchInformation success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getNetworkSearchInformation fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.getNrOptionMode<sup>8+</sup>
getNrOptionMode(callback: AsyncCallback<NrOptionMode\>): void
Obtains the NR option mode. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<[NrOptionMode](#nroptionmode8)\> | Yes | Callback used to return the result.|
**Example**
```js
radio.getNrOptionMode((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getNrOptionMode<sup>8+</sup>
getNrOptionMode(slotId: number, callback: AsyncCallback<NrOptionMode\>): void
Obtains the NR option mode. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[NrOptionMode](#nroptionmode8)\> | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
radio.getNrOptionMode(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getNrOptionMode<sup>8+</sup>
getNrOptionMode(slotId?: number): Promise<NrOptionMode\>
Obtains the NR option mode. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ----------------------------------------- | ----------------------- |
| Promise\<[NrOptionMode](#nroptionmode8)\> | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let promise = radio.getNrOptionMode(slotId);
promise.then(data => {
console.log(`getNrOptionMode success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getNrOptionMode fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.turnOnRadio<sup>7+</sup>
turnOnRadio(callback: AsyncCallback<void\>): void
Turns on the radio function. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------- |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
```js
radio.turnOnRadio((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.turnOnRadio<sup>7+</sup>
turnOnRadio(slotId: number, callback: AsyncCallback<void\>): void
Turns on the radio function for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
radio.turnOnRadio(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.turnOnRadio<sup>7+</sup>
turnOnRadio(slotId?: number): Promise<void\>
Turns on the radio function for the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| --------------- | ----------------------- |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let promise = radio.turnOnRadio(slotId);
promise.then(data => {
console.log(`turnOnRadio success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`turnOnRadio fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.turnOffRadio<sup>7+</sup>
turnOffRadio(callback: AsyncCallback<void\>): void
Turns off the radio function. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | ---------- |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result.|
**Example**
```js
radio.turnOffRadio((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.turnOffRadio<sup>7+</sup>
turnOffRadio(slotId: number, callback: AsyncCallback<void\>): void
Turns off the radio function for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
radio.turnOffRadio(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.turnOffRadio<sup>7+</sup>
turnOffRadio(slotId?: number): Promise<void\>
Turns off the radio function for the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | No | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| --------------- | ----------------------- |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let promise = radio.turnOffRadio(slotId);
promise.then(data => {
console.log(`turnOffRadio success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`turnOffRadio fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.setPreferredNetwork<sup>8+</sup>
setPreferredNetwork\(slotId: number, networkMode: PreferredNetworkMode, callback: AsyncCallback<void\>\): void
Sets the preferred network. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| networkMode | [PreferredNetworkMode](#preferrednetworkmode8) | Yes | Preferred network mode. |
| callback | AsyncCallback\<void\> | Yes | Callback used to return the result. |
**Example**
```js
radio.setPreferredNetwork(0, 1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.setPreferredNetwork<sup>8+</sup>
setPreferredNetwork(slotId: number, networkMode: PreferredNetworkMode): Promise<void\>
Sets the preferred network. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| ----------- | ---------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| networkMode | [PreferredNetworkMode](#preferrednetworkmode8) | Yes | Preferred network mode. |
**Return value**
| Type | Description |
| --------------- | ----------------------- |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let promise = radio.setPreferredNetwork(0, 1);
promise.then(data => {
console.log(`setPreferredNetwork success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`setPreferredNetwork fail, promise: err->${JSON.stringify(err)}`);
});
```
## radio.getPreferredNetwork<sup>8+</sup>
getPreferredNetwork\(slotId: number, callback: AsyncCallback<PreferredNetworkMode\>\): void
Obtains the preferred network. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[PreferredNetworkMode](#preferrednetworkmode8)\> | Yes | Callback used to return the result. |
**Example**
```js
radio.getPreferredNetwork(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## radio.getPreferredNetwork<sup>8+</sup>
getPreferredNetwork(slotId: number): Promise<void\>
Obtains the preferred network. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| --------------- | ----------------------- |
| Promise\<void\> | Promise used to return the result.|
**Example**
```js
let promise = radio.getPreferredNetwork(0);
promise.then(data => {
console.log(`getPreferredNetwork success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getPreferredNetwork fail, promise: err->${JSON.stringify(err)}`);
});
```
## RadioTechnology ## RadioTechnology
Enumerates the RAT. Enumerates radio access technologies.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
...@@ -1010,3 +1699,238 @@ Enumerates network selection modes. ...@@ -1010,3 +1699,238 @@ Enumerates network selection modes.
| NETWORK_SELECTION_UNKNOWN | 0 | Unknown network selection mode.| | NETWORK_SELECTION_UNKNOWN | 0 | Unknown network selection mode.|
| NETWORK_SELECTION_AUTOMATIC | 1 | Automatic network selection mode.| | NETWORK_SELECTION_AUTOMATIC | 1 | Automatic network selection mode.|
| NETWORK_SELECTION_MANUAL | 2 | Manual network selection mode.| | NETWORK_SELECTION_MANUAL | 2 | Manual network selection mode.|
## PreferredNetworkMode<sup>8+</sup>
Enumerates preferred network modes.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description |
| --------------------------------------------------------- | ---- | --------------------------------------------- |
| PREFERRED_NETWORK_MODE_GSM | 1 | GSM network mode. |
| PREFERRED_NETWORK_MODE_WCDMA | 2 | WCDMA network mode. |
| PREFERRED_NETWORK_MODE_LTE | 3 | LTE network mode. |
| PREFERRED_NETWORK_MODE_LTE_WCDMA | 4 | LTE+WCDMA network mode. |
| PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM | 5 | LTE+WCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_WCDMA_GSM | 6 | WCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_CDMA | 7 | CDMA network mode. |
| PREFERRED_NETWORK_MODE_EVDO | 8 | EVDO network mode. |
| PREFERRED_NETWORK_MODE_EVDO_CDMA | 9 | EVDO+CDMA network mode. |
| PREFERRED_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA | 10 | WCDMA+GSM+EVDO+CDMA network mode. |
| PREFERRED_NETWORK_MODE_LTE_EVDO_CDMA | 11 | LTE+EVDO+CDMA network mode. |
| PREFERRED_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA | 12 | LTE+WCDMA+GSM+EVDO+CDMA network mode. |
| PREFERRED_NETWORK_MODE_TDSCDMA | 13 | TD-SCDMA network mode. |
| PREFERRED_NETWORK_MODE_TDSCDMA_GSM | 14 | TD-SCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA | 15 | TD-SCDMA+WCDMA network mode. |
| PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM | 16 | TD-SCDMA+WCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_LTE_TDSCDMA | 17 | LTE+TD-SCDMA network mode. |
| PREFERRED_NETWORK_MODE_LTE_TDSCDMA_GSM | 18 | LTE+TD-SCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA | 19 | LTE+TD-SCDMA+WCDMA network mode. |
| PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM | 20 | LTE+TD-SCDMA+WCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA | 21 | TD-SCDMA+WCDMA+GSM+EVDO+CDMA network mode. |
| PREFERRED_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA | 22 | LTE+TD-SCDMA+WCDMA+GSM+EVDO+CDMA network mode.|
| PREFERRED_NETWORK_MODE_NR | 31 | NR network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE | 32 | NR+LTE network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_WCDMA | 33 | NR+LTE+WCDMA network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM | 34 | NR+LTE+WCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_EVDO_CDMA | 35 | NR+LTE+EVDO+CDMA network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA | 36 | NR+LTE+WCDMA+GSM+EVDO+CDMA network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA | 37 | NR+LTE+TD-SCDMA network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_GSM | 38 | NR+LTE+TD-SCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA | 39 | NR+LTE+TD-SCDMA+WCDMA network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM | 40 | NR+LTE+TD-SCDMA+WCDMA+GSM network mode. |
| PREFERRED_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA | 41 | NR+LTE+TD-SCDMA+WCDMA+GSM+EVDO+CDMA network mode. |
| PREFERRED_NETWORK_MODE_MAX_VALUE | 99 | Maximum value of the preferred network mode. |
## CellInformation<sup>8+</sup>
Defines the cell information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ----------------- | ------------------------------------------------------------ | ------------------------------------------------------------ |
| networkType | [NetworkType](#networkType) | Network type of the cell. |
| isCamped | boolean | Status of the cell. |
| timeStamp | number | Timestamp when cell information is obtained. |
| signalInformation | [SignalInformation](#signalinformation) | Signal information. |
| data | [CdmaCellInformation](#cdmacellinformation) \| [GsmCellInformation](#gsmcellinformation) \| [LteCellInformation](#ltecellinformation) \| [NrCellInformation](#nrcellinformation) \| [TdscdmaCellInformation](#tdscdmacellinformation) | CDMA cell information \| GSM cell information \| LTE cell information \| NR cell information \| TD-SCDMA cell information |
## CdmaCellInformation<sup>8+</sup>
Defines the CDMA cell information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| --------- | ------ | ------------ |
| baseId | number | Base station ID. |
| latitude | number | Longitude. |
| longitude | number | Latitude. |
| nid | number | Network ID.|
| sid | number | System ID.|
## GsmCellInformation<sup>8+</sup>
Defines the GSM cell information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ------ | ------ | -------------------- |
| lac | number | Location area code. |
| cellId | number | Cell ID. |
| arfcn | number | Absolute radio frequency channel number.|
| bsic | number | Base station ID. |
| mcc | string | Mobile country code. |
| mnc | string | Mobile network code. |
## LteCellInformation<sup>8+</sup>
Defines the LTE cell information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ------------- | ------- | ----------------------- |
| cgi | number | Cell global identification. |
| pci | number | Physical cell ID. |
| tac | number | Tracking area code. |
| earfcn | number | Absolute radio frequency channel number. |
| bandwidth | number | Bandwidth. |
| mcc | string | Mobile country code. |
| mnc | string | Mobile network code. |
| isSupportEndc | boolean | Support New Radio_Dual Connectivity|
## NrCellInformation<sup>8+</sup>
Defines the NR cell information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ------- | ------ | ---------------- |
| nrArfcn | number | 5G frequency number. |
| pci | number | Physical cell ID. |
| tac | number | Tracking area code. |
| nci | number | 5G network cell ID.|
| mcc | string | Mobile country code. |
| mnc | string | Mobile network code. |
## TdscdmaCellInformation<sup>8+</sup>
Defines the TD-SCDMA cell information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ------ | ------ | ------------ |
| lac | number | Location area code.|
| cellId | number | Cell ID. |
| cpid | number | Cell parameter ID.|
| uarfcn | number | Absolute radio frequency number.|
| mcc | string | Mobile country code.|
| mnc | string | Mobile network code. |
## WcdmaCellInformation<sup>8+</sup>
Defines the WCDMA cell information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ------ | ------ | ------------ |
| lac | number | Location area code.|
| cellId | number | Cell ID. |
| psc | number | Primary scrambling code. |
| uarfcn | number | Absolute radio frequency number.|
| mcc | string | Mobile country code.|
| mnc | string | Mobile network code. |
## NrOptionMode<sup>8+</sup>
Enumerates NR selection modes.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description |
| -------------------- | ---- | ---------------------------------- |
| NR_OPTION_UNKNOWN | 0 | Unknown NR selection mode. |
| NR_OPTION_NSA_ONLY | 1 | NR selection mode in 5G non-standalone networking. |
| NR_OPTION_SA_ONLY | 2 | NR selection mode in 5G standalone networking. |
| NR_OPTION_NSA_AND_SA | 3 | NR selection mode in non-standalone and standalone networking.|
## NetworkSearchResult
Defines the network search result.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ---------------------- | ------------------------------------------------- | -------------- |
| isNetworkSearchSuccess | boolean | Successful network search.|
| networkSearchResult | Array<[NetworkInformation](#networkinformation)\> | Network search result.|
## NetworkInformation
Defines the network information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| --------------- | ----------------------------------------- | -------------- |
| operatorName | string | Carrier name.|
| operatorNumeric | string | Carrier number. |
| state | [NetworkInformation](#networkinformationstate) | Network information status.|
| radioTech | string | Radio technology. |
## NetworkInformationState
Enumerates network information states.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description |
| ----------------- | ---- | ---------------- |
| NETWORK_UNKNOWN | 0 | Unknown state. |
| NETWORK_AVAILABLE | 1 | Available for registration.|
| NETWORK_CURRENT | 2 | Registered state.|
| NETWORK_FORBIDDEN | 3 | Unavailable for registration. |
## NetworkSelectionModeOptions
Defines the network selection mode.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ------------------ | --------------------------------------------- | -------------------------------------- |
| slotId | number | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| selectMode | [NetworkSelectionMode](#networkselectionmode) | Network selection mode. |
| networkInformation | [NetworkInformation](#networkinformation) | Network information. |
| resumeSelection | boolean | Whether to resume selection. |
...@@ -144,7 +144,7 @@ sim.hasOperatorPrivileges(0, (err, data) => { ...@@ -144,7 +144,7 @@ sim.hasOperatorPrivileges(0, (err, data) => {
hasOperatorPrivileges(slotId: number): Promise<boolean\> hasOperatorPrivileges(slotId: number): Promise<boolean\>
Checks whether the application (caller) has been granted the operator permission. This API uses a promise to return the result. Checks whether the application (caller) has been granted the carrier permission. This API uses a promise to return the result.
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
...@@ -158,7 +158,7 @@ Checks whether the application (caller) has been granted the operator permission ...@@ -158,7 +158,7 @@ Checks whether the application (caller) has been granted the operator permission
| Type | Description | | Type | Description |
| :----------------- | :---------------------------------------------------------- | | :----------------- | :---------------------------------------------------------- |
| Promise\<boolean\> | Promise used to return the result. The value **true** indicates that the application (caller) has been granted the operator permission, and the value **false** indicates the opposite.| | Promise\<boolean\> | Promise used to return the result. The value **true** indicates that the application (caller) has been granted the carrier permission, and the value **false** indicates the opposite.|
**Example** **Example**
...@@ -184,7 +184,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use ...@@ -184,7 +184,7 @@ Obtains the ISO country code of the SIM card in the specified slot. This API use
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | ---------------------------------------- | | -------- | ----------------------- | ---- | ---------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result, which is an ISO country code, for example, **CN** (China).| | callback | AsyncCallback\<string\> | Yes | Callback used to return the result. which is an ISO country code, for example, **CN** (China).|
**Example** **Example**
...@@ -467,7 +467,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an ...@@ -467,7 +467,7 @@ Checks whether the SIM card in the specified slot is installed. This API uses an
**Example** **Example**
```jsjs ```js
sim.hasSimCard(0, (err, data) => { sim.hasSimCard(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
...@@ -522,7 +522,7 @@ This is a system API. ...@@ -522,7 +522,7 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------- | ---- | -------------------------------------- | | -------- | --------------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[IccAccountInfo](#IccAccountInfo7)\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[IccAccountInfo](#iccaccountinfo7)\> | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -555,7 +555,7 @@ This is a system API. ...@@ -555,7 +555,7 @@ This is a system API.
| Type | Description | | Type | Description |
| -------------------------------------------- | ------------------------------------------ | | -------------------------------------------- | ------------------------------------------ |
| Promise<[IccAccountInfo](#IccAccountInfo7)\> | Promise used to return the result.| | Promise<[IccAccountInfo](#iccaccountinfo7)\> | Promise used to return the result.|
**Example** **Example**
...@@ -584,7 +584,7 @@ This is a system API. ...@@ -584,7 +584,7 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ---------- | | -------- | ----------------------------------------------------------- | ---- | ---------- |
| callback | AsyncCallback\<Array<[IccAccountInfo](#IccAccountInfo7)\>\> | Yes | Callback used to return the result.| | callback | AsyncCallback\<Array<[IccAccountInfo](#iccaccountinfo7)\>\> | Yes | Callback used to return the result.|
**Example** **Example**
...@@ -611,7 +611,7 @@ This is a system API. ...@@ -611,7 +611,7 @@ This is a system API.
| Type | Description | | Type | Description |
| ---------------------------------------------------- | ---------------------------------------------- | | ---------------------------------------------------- | ---------------------------------------------- |
| Promise<Array<[IccAccountInfo](#IccAccountInfo7)\>\> | Promise used to return the result.| | Promise<Array<[IccAccountInfo](#iccaccountinfo7)\>\> | Promise used to return the result.|
**Example** **Example**
...@@ -646,7 +646,7 @@ This is a system API. ...@@ -646,7 +646,7 @@ This is a system API.
**Example** **Example**
```js ```js
sim.setDefaultVoiceSlotId(0,(err, data) => { sim.setDefaultVoiceSlotId(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -672,9 +672,9 @@ This is a system API. ...@@ -672,9 +672,9 @@ This is a system API.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------------- | | --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result. | | Promise\<void\> | Promise used to return the result.|
**Example** **Example**
...@@ -711,7 +711,7 @@ This is a system API. ...@@ -711,7 +711,7 @@ This is a system API.
```js ```js
const name='China Mobile'; const name='China Mobile';
sim.setShowName(0, name,(err, data) => { sim.setShowName(0, name, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -737,15 +737,15 @@ This is a system API. ...@@ -737,15 +737,15 @@ This is a system API.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------------- | | --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result. | | Promise\<void\> | Promise used to return the result.|
**Example** **Example**
```js ```js
const name='China Mobile'; const name='China Mobile';
let promise = sim.setShowName(0,name); let promise = sim.setShowName(0, name);
promise.then(data => { promise.then(data => {
console.log(`setShowName success, promise: data->${JSON.stringify(data)}`); console.log(`setShowName success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -839,8 +839,8 @@ This is a system API. ...@@ -839,8 +839,8 @@ This is a system API.
**Example** **Example**
```js ```js
let number='+861xxxxxxxxxx'; let number = '+861xxxxxxxxxx';
sim.setShowNumber(0, number,(err, data) => { sim.setShowNumber(0, number, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -869,13 +869,13 @@ This is a system API. ...@@ -869,13 +869,13 @@ This is a system API.
| Type | Description | | Type | Description |
| -------------- | ------------------------------- | | -------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result. | | Promise<void\> | Promise used to return the result.|
**Example** **Example**
```js ```js
let number='+861xxxxxxxxxx'; let number = '+861xxxxxxxxxx';
let promise = sim.setShowNumber(0,number); let promise = sim.setShowNumber(0, number);
promise.then(data => { promise.then(data => {
console.log(`setShowNumber success, promise: data->${JSON.stringify(data)}`); console.log(`setShowNumber success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -994,9 +994,9 @@ This is a system API. ...@@ -994,9 +994,9 @@ This is a system API.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------------- | | --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result. | | Promise\<void\> | Promise used to return the result.|
**Example** **Example**
...@@ -1057,8 +1057,8 @@ This is a system API. ...@@ -1057,8 +1057,8 @@ This is a system API.
**Return value** **Return value**
| Type | Description | | Type | Description |
| -------------- | ------------------------------- | | --------------- | ------------------------------- |
| Promise\<void\> | Promise used to return the result.| | Promise\<void\> | Promise used to return the result.|
**Example** **Example**
...@@ -1089,16 +1089,18 @@ This is a system API. ...@@ -1089,16 +1089,18 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | | -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes | Callback used to return the result. |
| options | [LockInfo](#LockInfo8) | Yes | Lock information.<br>- **lockType**: [LockType](#LockType8)<br>- **password**: string<br>- **state**: [LockState](#LockState8) | | options | [LockInfo](#lockinfo8) | Yes | Lock information.<br>lockType: [LockType](#locktype8)<br>password: string<br>state: [LockState](#lockstate8) |
**Example** **Example**
```js ```js
LockInfo.lockType = 1; let lockInfo = {
LockInfo.password = "1234"; lockType = 1,
LockInfo.state = 0; password = "1234",
sim.setLockState(0, LockInfo, (err, data) => { state = 0
};
sim.setLockState(0, lockInfo, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1121,21 +1123,23 @@ This is a system API. ...@@ -1121,21 +1123,23 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------- | ---- | ------------------------------------------------------------ | | ------- | ---------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| options | [LockInfo](#LockInfo8) | Yes | Lock information.<br>- **lockType**: [LockType](#LockType8)<br>**password**: string<br>**state**: [LockState](#LockState8) | | options | [LockInfo](#lockinfo8) | Yes | Lock information.<br>lockType: [LockType](#locktype8)<br>password: string<br>state: [LockState](#lockstate8) |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------------------- | -------------------------------------------- | | ---------------------------------------------------- | -------------------------------------------- |
| Promise<[LockStatusResponse](#LockStatusResponse7)\> | Promise used to return the result.| | Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
**Example** **Example**
```js ```js
LockInfo.lockType = 1; let lockInfo = {
LockInfo.password = "1234"; lockType = 1,
LockInfo.state = 0; password = "1234",
let promise = sim.setLockState(0, LockInfo); state = 0
};
let promise = sim.setLockState(0, lockInfo);
promise.then(data => { promise.then(data => {
console.log(`setLockState success, promise: data->${JSON.stringify(data)}`); console.log(`setLockState success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -1158,8 +1162,8 @@ This is a system API. ...@@ -1158,8 +1162,8 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------- | ---- | --------------------------------------- | | -------- | ----------------------------------------- | ---- | --------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| callback | AsyncCallback\<[LockState](#LockState8)\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[LockState](#lockstate8)\> | Yes | Callback used to return the result. |
| options | [LockType](#LockType8) | Yes | Lock type.<br>- **1**: PIN lock<br>- **2**: PIN2 lock| | options | [LockType](#locktype8) | Yes | Lock type.<br>- **1**: PIN lock<br>- **2**: PIN 2 lock|
**Example** **Example**
...@@ -1185,13 +1189,13 @@ This is a system API. ...@@ -1185,13 +1189,13 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------- | ---- | --------------------------------------- | | ------- | ---------------------- | ---- | --------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 | | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| options | [LockType](#LockType8) | Yes | Lock type.<br>- **1**: PIN lock<br>- **2**: PIN2 lock| | options | [LockType](#locktype8) | Yes | Lock type.<br>- **1**: PIN lock<br>- **2**: PIN 2 lock|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | -------------------------------------------- | | ---------------------------------- | -------------------------------------------- |
| Promise<[LockState](#LockState8)\> | Promise used to return the result.| | Promise<[LockState](#lockstate8)\> | Promise used to return the result.|
**Example** **Example**
...@@ -1208,7 +1212,7 @@ promise.then(data => { ...@@ -1208,7 +1212,7 @@ promise.then(data => {
alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback<LockStatusResponse\>): void alterPin(slotId: number, newPin: string, oldPin: string, callback: AsyncCallback<LockStatusResponse\>): void
Changes the PIN. This API uses an asynchronous callback to return the result. Changes the PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
...@@ -1221,14 +1225,14 @@ This is a system API. ...@@ -1221,14 +1225,14 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- | | -------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes | Callback used to return the result. |
| newPin | string | Yes | New PIN. | | newPin | string | Yes | New PIN. |
| oldPin | string | Yes | Old PIN. | | oldPin | string | Yes | Old PIN. |
**Example** **Example**
```js ```js
sim.alterPin(0, "1234", "0000"(err, data) => { sim.alterPin(0, "1234", "0000", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1238,7 +1242,7 @@ sim.alterPin(0, "1234", "0000"(err, data) => { ...@@ -1238,7 +1242,7 @@ sim.alterPin(0, "1234", "0000"(err, data) => {
alterPin(slotId: number, newPin: string, oldPin: string): Promise<LockStatusResponse\>; alterPin(slotId: number, newPin: string, oldPin: string): Promise<LockStatusResponse\>;
Changes the PIN. This API uses a promise to return the result. Changes the PIN of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API. This is a system API.
...@@ -1258,7 +1262,7 @@ This is a system API. ...@@ -1258,7 +1262,7 @@ This is a system API.
| Type | Description | | Type | Description |
| ---------------------------------------------------- | --------------------------------------------- | | ---------------------------------------------------- | --------------------------------------------- |
| Promise<[LockStatusResponse](#LockStatusResponse7)\> | Promise used to return the result.| | Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
**Example** **Example**
...@@ -1275,7 +1279,7 @@ promise.then(data => { ...@@ -1275,7 +1279,7 @@ promise.then(data => {
alterPin2(slotId: number, newPin2: string, oldPin2: string, callback: AsyncCallback<LockStatusResponse\>): void alterPin2(slotId: number, newPin2: string, oldPin2: string, callback: AsyncCallback<LockStatusResponse\>): void
Changes PIN 2. This API uses an asynchronous callback to return the result. Changes PIN 2 of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
...@@ -1288,7 +1292,7 @@ This is a system API. ...@@ -1288,7 +1292,7 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | -------------------------------------- | | -------- | ----------------------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<[LockStatusResponse](#LockStatusResponse7)\> | Yes | Callback used to return the result. | | callback | AsyncCallback\<[LockStatusResponse](#lockstatusresponse7)\> | Yes | Callback used to return the result. |
| newPin2 | string | Yes | New PIN. | | newPin2 | string | Yes | New PIN. |
| oldPin2 | string | Yes | Old PIN. | | oldPin2 | string | Yes | Old PIN. |
...@@ -1305,7 +1309,7 @@ sim.alterPin2(0, "1234", "0000", (err, data) => { ...@@ -1305,7 +1309,7 @@ sim.alterPin2(0, "1234", "0000", (err, data) => {
alterPin2(slotId: number, newPin2: string, oldPin2: string): Promise<LockStatusResponse\> alterPin2(slotId: number, newPin2: string, oldPin2: string): Promise<LockStatusResponse\>
Changes PIN 2. This API uses a promise to return the result. Changes PIN 2 of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API. This is a system API.
...@@ -1325,12 +1329,12 @@ This is a system API. ...@@ -1325,12 +1329,12 @@ This is a system API.
| Type | Description | | Type | Description |
| ---------------------------------------------------- | --------------------------------------------- | | ---------------------------------------------------- | --------------------------------------------- |
| Promise<[LockStatusResponse](#LockStatusResponse7)\> | Promise used to return the result.| | Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
**Example** **Example**
```js ```js
let promise = sim.alterPin2(0, "1234","0000"); let promise = sim.alterPin2(0, "1234", "0000");
promise.then(data => { promise.then(data => {
console.log(`alterPin2 success, promise: data->${JSON.stringify(data)}`); console.log(`alterPin2 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -1342,7 +1346,7 @@ promise.then(data => { ...@@ -1342,7 +1346,7 @@ promise.then(data => {
unlockPin(slotId: number,pin: string ,callback: AsyncCallback<LockStatusResponse\>): void unlockPin(slotId: number,pin: string ,callback: AsyncCallback<LockStatusResponse\>): void
Unlocks the PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result. Unlocks PIN of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
...@@ -1356,13 +1360,13 @@ This is a system API. ...@@ -1356,13 +1360,13 @@ This is a system API.
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| pin | string | Yes | PIN of the SIM card. | | pin | string | Yes | PIN of the SIM card. |
| callback | AsyncCallback&lt;[LockStatusResponse](#LockStatusResponse7)> | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)> | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
let pin='1234'; let pin = '1234';
sim.unlockPin(0, pin,(err, data) => { sim.unlockPin(0, pin, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1391,13 +1395,13 @@ This is a system API. ...@@ -1391,13 +1395,13 @@ This is a system API.
| Type | Description | | Type | Description |
| ---------------------------------------------------- | -------------------------------------------------- | | ---------------------------------------------------- | -------------------------------------------------- |
| Promise\<[LockStatusResponse](#LockStatusResponse)\> | Promise used to return the result.| | Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
**Example** **Example**
```js ```js
let pin='1234'; let pin = '1234';
let promise = sim.unlockPin(0,pin); let promise = sim.unlockPin(0, pin);
promise.then(data => { promise.then(data => {
console.log(`unlockPin success, promise: data->${JSON.stringify(data)}`); console.log(`unlockPin success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -1424,14 +1428,14 @@ This is a system API. ...@@ -1424,14 +1428,14 @@ This is a system API.
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| newPin | string | Yes | New PIN. | | newPin | string | Yes | New PIN. |
| puk | string | Yes | PUK of the SIM card. | | puk | string | Yes | PUK of the SIM card. |
| callback | AsyncCallback&lt;[LockStatusResponse](#LockStatusResponse7)&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
let puk='1xxxxxxx'; let puk = '1xxxxxxx';
let newPin='1235'; let newPin = '1235';
sim.unlockPuk(0, newPin,puk,(err, data) => { sim.unlockPuk(0, newPin, puk, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1461,14 +1465,14 @@ This is a system API. ...@@ -1461,14 +1465,14 @@ This is a system API.
| Type | Description | | Type | Description |
| ---------------------------------------------------- | -------------------------------------------------- | | ---------------------------------------------------- | -------------------------------------------------- |
| Promise\<[LockStatusResponse](#LockStatusResponse)\> | Promise used to return the result.| | Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
**Example** **Example**
```js ```js
let puk='1xxxxxxx'; let puk = '1xxxxxxx';
let newPin='1235'; let newPin = '1235';
let promise = sim.unlockPuk(0,newPin,puk); let promise = sim.unlockPuk(0, newPin, puk);
promise.then(data => { promise.then(data => {
console.log(`unlockPuk success, promise: data->${JSON.stringify(data)}`); console.log(`unlockPuk success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -1493,14 +1497,14 @@ This is a system API. ...@@ -1493,14 +1497,14 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| pin2 | string | Yes | PIN of the SIM card. | | pin2 | string | Yes | PIN 2 of the SIM card. |
| callback | AsyncCallback&lt;[LockStatusResponse](#LockStatusResponse7)&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
let pin2='1234'; let pin2 = '1234';
sim.unlockPin2(0, pin2,(err, data) => { sim.unlockPin2(0, pin2, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1523,13 +1527,13 @@ This is a system API. ...@@ -1523,13 +1527,13 @@ This is a system API.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- | | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| pin2 | string | Yes | PIN of the SIM card. | | pin2 | string | Yes | PIN 2 of the SIM card. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ----------------------------------------------------- | -------------------------------------------------- | | ----------------------------------------------------- | -------------------------------------------------- |
| Promise\<[LockStatusResponse](#LockStatusResponse7)\> | Promise used to return the result.| | Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
**Example** **Example**
...@@ -1560,16 +1564,16 @@ This is a system API. ...@@ -1560,16 +1564,16 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | -------------------------------------- | | -------- | ------------------------------------------------------------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| newPin2 | string | Yes | New PIN. | | newPin2 | string | Yes | New PIN 2. |
| puk2 | string | Yes | PUK of the SIM card. | | puk2 | string | Yes | PUK 2 of the SIM card. |
| callback | AsyncCallback&lt;[LockStatusResponse](#LockStatusResponse7)&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;[LockStatusResponse](#lockstatusresponse7)&gt; | Yes | Callback used to return the result. |
**Example** **Example**
```js ```js
let puk2='1xxxxxxx'; let puk2 = '1xxxxxxx';
let newPin2='1235'; let newPin2 = '1235';
sim.unlockPuk2(0, newPin2,puk2,(err, data) => { sim.unlockPuk2(0, newPin2, puk2, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
}); });
``` ```
...@@ -1592,21 +1596,21 @@ This is a system API. ...@@ -1592,21 +1596,21 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------ | ---- | -------------------------------------- | | ------- | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| newPin2 | string | Yes | New PIN. | | newPin2 | string | Yes | New PIN 2. |
| puk2 | string | Yes | PUK of the SIM card. | | puk2 | string | Yes | PUK 2 of the SIM card. |
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------------------- | -------------------------------------------------- | | ---------------------------------------------------- | -------------------------------------------------- |
| Promise\<[LockStatusResponse](#LockStatusResponse)\> | Promise used to return the result.| | Promise\<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
**Example** **Example**
```js ```js
let puk2='1xxxxxxx'; let puk2 = '1xxxxxxx';
let newPin2='1235'; let newPin2 = '1235';
let promise = sim.unlockPuk2(0,newPin2,puk2); let promise = sim.unlockPuk2(0, newPin2, puk2);
promise.then(data => { promise.then(data => {
console.log(`unlockPuk2 success, promise: data->${JSON.stringify(data)}`); console.log(`unlockPuk2 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => { }).catch(err => {
...@@ -1634,142 +1638,1313 @@ Obtains the number of card slots. ...@@ -1634,142 +1638,1313 @@ Obtains the number of card slots.
console.log("Result: "+ sim.getMaxSimCount()) console.log("Result: "+ sim.getMaxSimCount())
``` ```
## sim.getSimIccId<sup>7+</sup>
## SimState getSimIccId(slotId: number, callback: AsyncCallback<string\>): void
Enumerates SIM card states. Obtains the IC card identity (ICCID) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description | **Parameters**
| --------------------- | ---- | ---------------------------------------------------------- |
| SIM_STATE_UNKNOWN | 0 | The SIM card is in **unknown** state; that is, the SIM card status cannot be obtained. |
| SIM_STATE_NOT_PRESENT | 1 | The SIM card is in **not present** state; that is, no SIM card is inserted into the card slot. |
| SIM_STATE_LOCKED | 2 | The SIM card is in **locked** state; that is, the SIM card is locked by the personal identification number (PIN), PIN unblocking key (PUK), or network. |
| SIM_STATE_NOT_READY | 3 | The SIM card is in **not ready** state; that is, the SIM card has been installed but cannot work properly. |
| SIM_STATE_READY | 4 | The SIM card is in **ready** state; that is, the SIM card has been installed and is working properly. |
| SIM_STATE_LOADED | 5 | The SIM card is in **loaded** state; that is, the SIM card is present and all its files have been loaded.|
## CardType<sup>7+</sup> | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes | Callback used to return the result. |
**Example**
```js
sim.getSimIccId(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getSimIccId<sup>7+</sup>
getSimIccId(slotId: number): Promise<string\>
Obtains the ICCID of the SIM card in the specified slot. This API uses a promise to return the result.
Enumerates card types. This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name| Value| Description| **Parameters**
| ----- | ----- | ----- |
|UNKNOWN_CARD | -1 | Unknown|
|SINGLE_MODE_SIM_CARD | 10 | Single-card (SIM)|
|SINGLE_MODE_USIM_CARD | 20 | Single-card (USIM)|
|SINGLE_MODE_RUIM_CARD | 30 | Single-card (RUIM)|
|DUAL_MODE_CG_CARD | 40 | Dual-card (CDMA+GSM)|
|CT_NATIONAL_ROAMING_CARD | 41 | China Telecom internal roaming card|
|CU_DUAL_MODE_CARD | 42 | China Unicom dual-mode card|
|DUAL_MODE_TELECOM_LTE_CARD | 43 | China Telecom dual-mode LTE card|
|DUAL_MODE_UG_CARD | 50 | Dual-mode card (UMTS+GSM)|
|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | Single-card (ISIM)|
## LockType<sup>8+</sup> | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
Enumerates lock types. **Return value**
| Type | Description |
| ---------------- | ------------------------------------------- |
| Promise<string\> | Promise used to return the result.|
**Example**
```js
let promise = sim.getSimIccId(0);
promise.then(data => {
console.log(`getSimIccId success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getSimIccId fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.getVoiceMailIdentifier<sup>8+</sup>
getVoiceMailIdentifier(slotId: number, callback: AsyncCallback<string\>): void
Obtains the voice mailbox alpha identifier of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description | **Parameters**
| -------- | ---- | ----------- |
| PIN_LOCK | 1 | SIM card password lock|
| FDN_LOCK | 2 | Fixed dialing lock |
## LockState<sup>8+</sup> | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes | Callback used to return the result. |
**Example**
```js
sim.getVoiceMailIdentifier(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
Enumerates lock states.
## sim.getVoiceMailIdentifier<sup>8+</sup>
getVoiceMailIdentifier(slotId: number): Promise<string\>
Obtains the voice mailbox alpha identifier of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API. This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description | **Parameters**
| -------- | ---- | ---------- |
| LOCK_OFF | 0 | The lock is off.| | Name| Type | Mandatory| Description |
| LOCK_ON | 1 | The lock is on.| | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
## **PersoLockType**<sup>8+</sup> **Return value**
Enumerates personalized lock types. | Type | Description |
| ---------------- | ------------------------------------------------- |
| Promise<string\> | Promise used to return the result.|
**Example**
```js
let promise = sim.getVoiceMailIdentifier(0);
promise.then(data => {
console.log(`getVoiceMailIdentifier success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getVoiceMailIdentifier fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.getVoiceMailNumber<sup>8+</sup>
getVoiceMailNumber(slotId: number, callback: AsyncCallback<string\>): void
Obtains the voice mailbox number of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description | **Parameters**
| ------------ | ---- | ----------------------------------------------- |
| PN_PIN_LOCK | 0 | Personalized network PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PN_PUK_LOCK | 1 | Personalized network PUK lock. |
| PU_PIN_LOCK | 2 | Personalized network subset PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PU_PUK_LOCK | 3 | Personalized network subset PUK lock. |
| PP_PIN_LOCK | 4 | Personalized service provider PIN lock. For details, see *3GPP TS 22.022 [33]*.|
| PP_PUK_LOCK | 5 | Personalized service provider PUK lock. |
| PC_PIN_LOCK | 6 | Personalized corporate PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PC_PUK_LOCK | 7 | Personalized corporate PUK lock. |
| SIM_PIN_LOCK | 8 | Personalized SIM card PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| SIM_PUK_LOCK | 9 | Personalized SIM card PUK lock. |
## **LockStatusResponse**<sup>7+</sup> | Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes | Callback used to return the result. |
Defines the lock status response. **Example**
```js
sim.getVoiceMailNumber(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getVoiceMailNumber<sup>8+</sup>
getVoiceMailNumber(slotId: number): Promise<string\>
Obtains the voice mailbox number of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API. This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | **Parameters**
| --------------- | ------ | ------------------ |
| result | number | Operation result. | | Name| Type | Mandatory| Description |
| remain?: number | number | Remaining attempts (can be null).| | ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ---------------- | ------------------------------------------------ |
| Promise<string\> | Promise used to return the result.|
**Example**
```js
let promise = sim.getVoiceMailNumber(0);
promise.then(data => {
console.log(`getVoiceMailNumber success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getVoiceMailNumber fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.setVoiceMailInfo<sup>8+</sup>
## **LockInfo**<sup>8+</sup> setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string, callback: AsyncCallback<void\>): void
Defines the personalized lock status response. Sets voice mailbox information for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | **Parameters**
| -------- | --------- | ------ |
| lockType | LockType | Lock type.|
| password | string | Password. |
| state | LockState | Lock state.|
## **PersoLockInfo**<sup>8+</sup> | Name | Type | Mandatory| Description |
| ---------- | -------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| mailName | string | Yes | Voice mailbox name. |
| mailNumber | string | Yes | Voice mailbox number. |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
Defines the personalized lock information. **Example**
```js
sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com" , (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.setVoiceMailInfo<sup>8+</sup>
setVoiceMailInfo(slotId: number, mailName: string, mailNumber: string): Promise<void\>
Sets voice mailbox information for the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API. This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | **Parameters**
| -------- | ------------- | ------------ |
| lockType | PersoLockType | Personalized lock type.|
| password | string | Password. |
## **IccAccountInfo**<sup>7+</sup> | Name | Type | Mandatory| Description |
| ---------- | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| mailName | string | Yes | Voice mailbox name. |
| mailNumber | string | Yes | Voice mailbox number. |
Defines the ICC account information. **Return value**
| Type | Description |
| -------------- | ----------------------- |
| Promise<void\> | Promise used to return the result.|
**Example**
```js
let promise = sim.setVoiceMailInfo(0, "mail", "xxx@xxx.com");
promise.then(data => {
console.log(`setVoiceMailInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`setVoiceMailInfo fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.getSimTelephoneNumber<sup>8+</sup>
getSimTelephoneNumber(slotId: number, callback: AsyncCallback<string\>): void
Obtains the mobile subscriber ISDN number (MSISDN) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API. This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService **System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description | **Parameters**
| ---------- | ------- | ---------------- |
| simId | number | SIM card ID. | | Name | Type | Mandatory| Description |
| slotIndex | number | Card slot ID. | | -------- | ---------------------- | ---- | -------------------------------------- |
| isEsim | boolean | Whether the SIM card is an eSim card.| | slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| isActive | boolean | Whether the card is activated. | | callback | AsyncCallback<string\> | Yes | Callback used to return the result. |
| iccId | string | ICCID number. |
| showName | string | SIM card display name. | **Example**
| showNumber | string | SIM card display number. |
```js
sim.getSimTelephoneNumber(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getSimTelephoneNumber<sup>8+</sup>
getSimTelephoneNumber(slotId: number): Promise<string\>
Obtains the MSISDN of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ---------------- | -------------------------------------------- |
| Promise<string\> | Promise used to return the result.|
**Example**
```js
let promise = sim.getSimTelephoneNumber(0);
promise.then(data => {
console.log(`getSimTelephoneNumber success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getSimTelephoneNumber fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.getSimGid1<sup>7+</sup>
getSimGid1(slotId: number, callback: AsyncCallback<string\>): void
Obtains the group identifier level 1 (GID1) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. |
**Example**
```js
sim.getSimGid1(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getSimGid1<sup>7+</sup>
getSimGid1(slotId: number): Promise<string\>
Obtains the GID1 of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ---------------- | ------------------------------------------------- |
| Promise<string\> | Promise used to return the result.|
**Example**
```js
let promise = sim.getSimGid1(0);
promise.then(data => {
console.log(`getSimGid1 success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getSimGid1 fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.getIMSI
getIMSI(slotId: number, callback: AsyncCallback<string\>): void
Obtains the international mobile subscriber identity (IMSI) of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback\<string\> | Yes | Callback used to return the result. |
**Example**
```js
sim.getIMSI(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getIMSI
getIMSI(slotId: number): Promise<string\>
Obtains the IMSI of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ---------------- | ------------------------------------------- |
| Promise<string\> | Promise used to return the result.|
**Example**
```js
let promise = sim.getIMSI(0);
promise.then(data => {
console.log(`getIMSI success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getIMSI fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.getOperatorConfigs<sup>8+</sup>
getOperatorConfigs(slotId: number, callback: AsyncCallback<Array<OperatorConfig\>>): void
Obtains the carrier configuration of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<Array<[OperatorConfig](#operatorconfig8)\>> | Yes | Callback used to return the result. |
**Example**
```js
sim.getOperatorConfigs(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getOperatorConfigs<sup>8+</sup>
getOperatorConfigs(slotId: number): Promise<Array<OperatorConfig\>>
Obtains the carrier configuration of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.GET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| --------------------------------------------------- | ----------------------------- |
| Promise<Array<[OperatorConfig](#operatorconfig8)\>> | Promise used to return the result.|
**Example**
```js
let promise = sim.getOperatorConfigs(0);
promise.then(data => {
console.log(`getOperatorConfigs success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getOperatorConfigs fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.queryIccDiallingNumbers<sup>8+</sup>
queryIccDiallingNumbers(slotId: number, type: ContactType, callback: AsyncCallback<Array<DiallingNumbersInfo\>>): void
Queries contact numbers of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------------------------------ | ---- | ---------------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| type | [ContactType](#contacttype8) | Yes | Contact type.<br>1 : GENERAL_CONTACT<br>2 : FIXED_DIALING |
| callback | AsyncCallback<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | Yes | Callback used to return the result. |
**Example**
```js
sim.queryIccDiallingNumbers(0, 1, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.queryIccDiallingNumbers<sup>8+</sup>
queryIccDiallingNumbers(slotId: number, type: ContactType): Promise<Array<DiallingNumbersInfo\>>
Queries contact numbers of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Permission required**: ohos.permission.READ_CONTACTS
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ----------- | ---- | ---------------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| type | [ContactType](#contacttype8) | Yes | Contact type.<br>1 : GENERAL_CONTACT<br>2 : FIXED_DIALING |
**Return value**
| Type | Description |
| ------------------------------------------------------------ | ------------------------------ |
| Promise<Array<[DiallingNumbersInfo](#diallingnumbersinfo8)\>> | Promise used to return the result.|
**Example**
```js
let promise = sim.queryIccDiallingNumbers(0, 1);
promise.then(data => {
console.log(`queryIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`queryIccDiallingNumbers fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.addIccDiallingNumbers<sup>8+</sup>
addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void
Adds contact numbers for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Permission required**: ohos.permission.WRITE_CONTACTS
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| type | [ContactType](#contacttype8) | Yes | Contact type.<br>**1**: GENERAL_CONTACT<br>**2**: FIXED_DIALING |
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes | Contact number information. |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
**Example**
```js
let diallingNumbersInof = {
alphaTag = "alpha",
number = "138xxxxxxxx",
recordNumber = 123,
pin2 = "1234"
};
sim.addIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.addIccDiallingNumbers<sup>8+</sup>
addIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\>
Adds contact numbers for the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Permission required**: ohos.permission.WRITE_CONTACTS
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| type | [ContactType](#contacttype8) | Yes | Contact type.<br>**1**: GENERAL_CONTACT<br>**2**: FIXED_DIALING |
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes | Contact number information. |
**Return value**
| Type | Description |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
**Example**
```js
let diallingNumbersInof = {
alphaTag = "alpha",
number = "138xxxxxxxx",
recordNumber = 123,
pin2 = "1234"
};
let promise = sim.addIccDiallingNumbers(0, 1, diallingNumbersInof);
promise.then(data => {
console.log(`addIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`addIccDiallingNumbers fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.delIccDiallingNumbers<sup>8+</sup>
delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void
Deletes contact numbers from the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Permission required**: ohos.permission.WRITE_CONTACTS
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| type | [ContactType](#contacttype8) | Yes | Contact type.<br>**1**: GENERAL_CONTACT<br>**2**: FIXED_DIALING |
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes | Contact number information. |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
**Example**
```js
let diallingNumbersInof = {
alphaTag = "alpha",
number = "138xxxxxxxx",
recordNumber = 123,
pin2 = "1234"
};
sim.delIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.delIccDiallingNumbers<sup>8+</sup>
delIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\>
Deletes contact numbers from the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Permission required**: ohos.permission.WRITE_CONTACTS
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| type | [ContactType](#contacttype8) | Yes | Contact type.<br>**1**: GENERAL_CONTACT<br>**2**: FIXED_DIALING |
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes | Contact number information. |
**Return value**
| Type | Description |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
**Example**
```js
let diallingNumbersInof = {
alphaTag = "alpha",
number = "138xxxxxxxx",
recordNumber = 123,
pin2 = "1234"
};
let promise = sim.delIccDiallingNumbers(0, 1, diallingNumbersInof);
promise.then(data => {
console.log(`delIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`delIccDiallingNumbers fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.updateIccDiallingNumbers<sup>8+</sup>
updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo, callback: AsyncCallback<void\>): void
Updates contact numbers for the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Permission required**: ohos.permission.WRITE_CONTACTS
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| type | [ContactType](#contacttype8) | Yes | Contact type.<br>**1**: GENERAL_CONTACT<br>**2**: FIXED_DIALING |
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes | Contact number information. |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
**Example**
```js
let diallingNumbersInof = {
alphaTag = "alpha",
number = "138xxxxxxxx",
recordNumber = 123,
pin2 = "1234"
};
sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.updateIccDiallingNumbers<sup>8+</sup>
updateIccDiallingNumbers(slotId: number, type: ContactType, diallingNumbers: DiallingNumbersInfo): Promise<void\>
Updates contact numbers for the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Permission required**: ohos.permission.WRITE_CONTACTS
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | -------------------------------------------- | ---- | ---------------------------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2 |
| type | [ContactType](#contacttype8) | Yes | Contact type.<br>**1**: GENERAL_CONTACT<br>**2**: FIXED_DIALING |
| diallingNumbers | [DiallingNumbersInfo](#diallingnumbersinfo8) | Yes | Contact number information. |
**Return value**
| Type | Description |
| -------------- | ----------------------------- |
| Promise<void\> | Promise used to return the result.|
**Example**
```js
let diallingNumbersInof = {
alphaTag = "alpha",
number = "138xxxxxxxx",
recordNumber = 123,
pin2 = "1234"
};
let promise = sim.updateIccDiallingNumbers(0, 1, diallingNumbersInof);
promise.then(data => {
console.log(`updateIccDiallingNumbers success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`updateIccDiallingNumbers fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.sendEnvelopeCmd<sup>8+</sup>
sendEnvelopeCmd(slotId: number, cmd: string, callback: AsyncCallback<void\>): void
Sends an envelope command to the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| cmd | string | Yes | Envelope command. |
| callback | AsyncCallback<void\> | Yes | Yes |
**Example**
```js
sim.sendEnvelopeCmd(0, "ls", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.sendEnvelopeCmd<sup>8+</sup>
sendEnvelopeCmd(slotId: number, cmd: string): Promise<void\>
Sends an envelope command to the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| cmd | string | Yes | Envelope command. |
**Return value**
| Type | Description |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
**Example**
```js
let promise = sim.sendEnvelopeCmd(0, "ls");
promise.then(data => {
console.log(`sendEnvelopeCmd success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`sendEnvelopeCmd fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.sendTerminalResponseCmd<sup>8+</sup>
sendTerminalResponseCmd(slotId: number, cmd: string, callback: AsyncCallback<void\>): void
Sends a terminal response command to the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| cmd | string | Yes | Command |
| callback | AsyncCallback<void\> | Yes | Callback used to return the result. |
**Example**
```js
sim.sendTerminalResponseCmd(0, "ls", (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.sendTerminalResponseCmd<sup>8+</sup>
sendTerminalResponseCmd(slotId: number, cmd: string): Promise<void\>
Sends a terminal response command to the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| cmd | string | Yes | Command |
**Return value**
| Type | Description |
| -------------- | --------------------------- |
| Promise<void\> | Promise used to return the result.|
**Example**
```js
let promise = sim.sendTerminalResponseCmd(0, "ls");
promise.then(data => {
console.log(`sendTerminalResponseCmd success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`sendTerminalResponseCmd fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.unlockSimLock<sup>8+</sup>
unlockSimLock(slotId: number, lockInfo: PersoLockInfo, callback: AsyncCallback<LockStatusResponse\>): void
Unlocks the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| lockInfo | [PersoLockInfo](#persolockinfo8) | Yes | Personalized lock information. |
| callback | AsyncCallback<[LockStatusResponse](#lockstatusresponse7)\> | Yes | Callback used to return the result. |
**Example**
```js
let persoLockInfo = {
lockType = 0,
password = "1234"
};
sim.unlockSimLock(0, persoLockInfo, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.unlockSimLock<sup>8+</sup>
unlockSimLock(slotId: number, lockInfo: PersoLockInfo): Promise<LockStatusResponse\>
Unlocks the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SET_TELEPHONY_STATE
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | -------------------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| lockInfo | [PersoLockInfo](#persolockinfo8) | Yes | Personalized lock information. |
**Return value**
| Type | Description |
| ---------------------------------------------------- | ------------------------- |
| Promise<[LockStatusResponse](#lockstatusresponse7)\> | Promise used to return the result.|
**Example**
```js
let persoLockInfo = {
lockType = 0,
password = "1234"
};
let promise = sim.unlockSimLock(0, persoLockInfo);
promise.then(data => {
console.log(`unlockSimLock success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`unlockSimLock fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.getOpKey<sup>9+</sup>
getOpKey(slotId: number, callback: AsyncCallback<number\>): void
Obtains the opkey of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<number\> | Yes | Callback used to return the result. |
**Example**
```js
sim.getOpKey(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getOpKey<sup>9+</sup>
getOpKey(slotId: number): Promise<number\>
Obtains the opkey of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ---------------- | ----------------------------------------- |
| Promise<number\> | Promise used to return the result.|
**Example**
```js
let promise = sim.getOpKey(0);
promise.then(data => {
console.log(`getOpKey success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getOpKey fail, promise: err->${JSON.stringify(err)}`);
});
```
## sim.getOpName<sup>9+</sup>
getOpName(slotId: number, callback: AsyncCallback<string\>): void
Obtains the OpName of the SIM card in the specified slot. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------- | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<string\> | Yes | Callback used to return the result. |
**Example**
```js
sim.getOpName(0, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sim.getOpName<sup>9+</sup>
getOpName(slotId: number): Promise<string\>
Obtains the OpName of the SIM card in the specified slot. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------------------- |
| slotId | number | Yes | Card slot ID.<br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ---------------- | ------------------------------------------ |
| Promise<string\> | Promise used to return the result.|
**Example**
```js
let promise = sim.getOpName(0);
promise.then(data => {
console.log(`getOpName success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.log(`getOpName fail, promise: err->${JSON.stringify(err)}`);
});
```
## SimState
Enumerates SIM card states.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description |
| --------------------- | ---- | ---------------------------------------------------------- |
| SIM_STATE_UNKNOWN | 0 | The SIM card is in **unknown** state; that is, the SIM card status cannot be obtained. |
| SIM_STATE_NOT_PRESENT | 1 | The SIM card is in **not present** state; that is, no SIM card is inserted into the card slot. |
| SIM_STATE_LOCKED | 2 | The SIM card is in **locked** state; that is, the SIM card is locked by the personal identification number (PIN), PIN unblocking key (PUK), or network. |
| SIM_STATE_NOT_READY | 3 | The SIM card is in **not ready** state; that is, the SIM card has been installed but cannot work properly. |
| SIM_STATE_READY | 4 | The SIM card is in **ready** state; that is, the SIM card has been installed and is working properly. |
| SIM_STATE_LOADED | 5 | The SIM card is in **loaded** state; that is, the SIM card is present and all its files have been loaded.|
## CardType<sup>7+</sup>
Enumerates SIM card types.
**System capability**: SystemCapability.Telephony.CoreService
| Name| Value| Description|
| ----- | ----- | ----- |
|UNKNOWN_CARD | -1 | Unknown|
|SINGLE_MODE_SIM_CARD | 10 | Single-card (SIM)|
|SINGLE_MODE_USIM_CARD | 20 | Single-card (USIM)|
|SINGLE_MODE_RUIM_CARD | 30 | Single-card (RUIM)|
|DUAL_MODE_CG_CARD | 40 | Dual-card (CDMA+GSM)|
|CT_NATIONAL_ROAMING_CARD | 41 | China Telecom internal roaming card|
|CU_DUAL_MODE_CARD | 42 | China Unicom dual-mode card|
|DUAL_MODE_TELECOM_LTE_CARD | 43 | China Telecom dual-mode LTE card|
|DUAL_MODE_UG_CARD | 50 | Dual-mode card (UMTS+GSM)|
|SINGLE_MODE_ISIM_CARD<sup>8+</sup> | 60 | Single-card (ISIM)|
## LockType<sup>8+</sup>
Enumerates lock types.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description |
| -------- | ---- | ----------- |
| PIN_LOCK | 1 | SIM card password lock.|
| FDN_LOCK | 2 | Fixed dialing lock. |
## LockState<sup>8+</sup>
Enumerates lock states.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description |
| -------- | ---- | ---------- |
| LOCK_OFF | 0 | The lock is off.|
| LOCK_ON | 1 | The lock is on.|
## PersoLockType<sup>8+</sup>
Enumerates personalized lock types.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description |
| ------------ | ---- | ----------------------------------------------- |
| PN_PIN_LOCK | 0 | Personalized network PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PN_PUK_LOCK | 1 | Personalized network PUK lock. |
| PU_PIN_LOCK | 2 | Personalized network subset PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PU_PUK_LOCK | 3 | Personalized network subset PUK lock. |
| PP_PIN_LOCK | 4 | Personalized service provider PIN lock. For details, see *3GPP TS 22.022 [33]*.|
| PP_PUK_LOCK | 5 | Personalized service provider PUK lock. |
| PC_PIN_LOCK | 6 | Personalized corporate PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| PC_PUK_LOCK | 7 | Personalized corporate PUK lock. |
| SIM_PIN_LOCK | 8 | Personalized SIM card PIN lock. For details, see *3GPP TS 22.022 [33]*. |
| SIM_PUK_LOCK | 9 | Personalized SIM card PUK lock. |
## LockStatusResponse<sup>7+</sup>
Defines the lock status response.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| --------------- | ------ | ------------------ |
| result | number | Operation result. |
| remain?: number | number | Remaining attempts (can be null).|
## LockInfo<sup>8+</sup>
Defines the lock information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| -------- | ------------------------ | ------ |
| lockType | [LockType](#locktype8) | Lock type.|
| password | string | Password. |
| state | [LockState](#lockstate8) | Lock state.|
## PersoLockInfo<sup>8+</sup>
Defines the personalized lock information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| -------- | -------------------------------- | ------------ |
| lockType | [PersoLockType](#persolocktype8) | Personalized lock type.|
| password | string | Password. |
## IccAccountInfo<sup>7+</sup>
Defines the ICC account information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ---------- | ------- | ---------------- |
| simId | number | SIM card ID. |
| slotIndex | number | Card slot ID. |
| isEsim | boolean | Whether the SIM card is an eSim card.|
| isActive | boolean | Whether the card is activated. |
| iccId | string | ICCID number. |
| showName | string | SIM card display name. |
| showNumber | string | SIM card display number. |
## OperatorConfig<sup>8+</sup>
Defines the carrier configuration.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description|
| ----- | ------ | ---- |
| field | string | Field|
| value | string | Value |
## DiallingNumbersInfo<sup>8+</sup>
Defines the contact number information.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Type | Description |
| ------------ | ------ | -------- |
| alphaTag | string | Alpha tag. |
| number | string | Contact number. |
| recordNumber | number | Record number.|
| pin2 | string | PIN 2.|
## ContactType<sup>8+</sup>
Enumerates contact types.
This is a system API.
**System capability**: SystemCapability.Telephony.CoreService
| Name | Value | Description |
| :-------------- | ---- | ---------- |
| GENERAL_CONTACT | 1 | Common contact number.|
| FIXED_DIALING | 2 | Fixed dialing number. |
...@@ -174,7 +174,7 @@ This is a system API. ...@@ -174,7 +174,7 @@ This is a system API.
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ------------------------------------------------------------ | | -------- | ------------------------- | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example** **Example**
...@@ -202,7 +202,7 @@ This is a system API. ...@@ -202,7 +202,7 @@ This is a system API.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ------------------------------------------------------------ | | ------ | ------ | ---- | ------------------------------------------------------------ |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: Clears the default configuration.| | slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2<br>- **-1**: clearing the default configuration|
**Return value** **Return value**
...@@ -360,7 +360,7 @@ promise.then(data => { ...@@ -360,7 +360,7 @@ promise.then(data => {
hasSmsCapability(): boolean hasSmsCapability(): boolean
Checks whether the current device can send and receive SMS messages. This API works in synchronous mode. Checks whether the current device can send and receive SMS messages. This API returns the result synchronously.
**System capability**: SystemCapability.Telephony.SmsMms **System capability**: SystemCapability.Telephony.SmsMms
...@@ -375,6 +375,739 @@ let result = sms.hasSmsCapability(); ...@@ -375,6 +375,739 @@ let result = sms.hasSmsCapability();
console.log(`hasSmsCapability: ${JSON.stringify(result)}`); console.log(`hasSmsCapability: ${JSON.stringify(result)}`);
``` ```
## sms.splitMessage<sup>8+</sup>
splitMessage(content: string, callback: AsyncCallback<Array<string\>>): void
Splits an SMS message into multiple segments. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------- | ---- | ----------------------------- |
| content | string | Yes | SMS message content. The value cannot be null.|
| callback | AsyncCallback<Array<string\>> | Yes | Callback used to return the result. |
**Example**
```js
string content= "long message";
sms.splitMessage(content, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.splitMessage<sup>8+</sup>
splitMessage(content: string): Promise<Array<string\>>
Splits an SMS message into multiple segments. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------ | ---- | ---------------------------- |
| content | string | Yes | SMS message content. The value cannot be null.|
**Return value**
| Type | Description |
| ----------------------- | ----------------------------------- |
| Promise<Array<string\>> | Promise used to return the result.|
**Example**
```js
string content = "long message";
let promise = sms.splitMessage(content);
promise.then(data => {
console.log(`splitMessage success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`splitMessage fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.addSimMessage<sup>7+</sup>
addSimMessage(options: SimMessageOptions, callback: AsyncCallback<void\>): void
Adds a SIM message. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | --------------- |
| options | [SimMessageOptions](#simmessageoptions7) | Yes | SIM message options.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let simMessageOptions = {
slotId = 0,
smsc = "test",
pdu = "xxxxxx",
status = 0
};
sms.addSimMessage(simMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.addSimMessage<sup>7+</sup>
addSimMessage(options: SimMessageOptions): Promise<void\>
Adds a SIM message. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | --------------- |
| options | [SimMessageOptions](#simmessageoptions7) | Yes | SIM message options.|
**Return value**
| Type | Description |
| ------------------- | ----------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let simMessageOptions = {
slotId = 0,
smsc = "test",
pdu = "xxxxxx",
status = 0
};
let promise = sms.addSimMessage(simMessageOptions);
promise.then(data => {
console.log(`addSimMessage success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`addSimMessage fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.delSimMessage<sup>7+</sup>
delSimMessage(slotId: number, msgIndex: number, callback: AsyncCallback<void\>): void
Deletes a SIM message. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------- | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| msgIndex | number | Yes | Message index. |
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
let msgIndex = 1;
sms.delSimMessage(slotId, msgIndex, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.delSimMessage<sup>7+</sup>
delSimMessage(slotId: number, msgIndex: number): Promise<void\>
Deletes a SIM message. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| msgIndex | number | Yes | Message index. |
**Return value**
| Type | Description |
| ------------------- | ----------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let msgIndex = 1;
let promise = sms.delSimMessage(slotId, msgIndex);
promise.then(data => {
console.log(`delSimMessage success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`delSimMessage fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.updateSimMessage<sup>7+</sup>
updateSimMessage(options: UpdateSimMessageOptions, callback: AsyncCallback<void\>): void
Updates a SIM message. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------------------------------- | ---- | ------------------- |
| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | Yes | SIM message updating options.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let updateSimMessageOptions = {
slotId = 0,
msgIndex = 1,
newStatus = 0,
pdu = "xxxxxxx",
smsc = "test"
};
sms.updateSimMessage(updateSimMessageOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.updateSimMessage<sup>7+</sup>
updateSimMessage(options: UpdateSimMessageOptions): Promise<void\>
Updates a SIM message. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS,ohos.permission.SEND_MESSAGES
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ---------------------------------------------------- | ---- | ------------------- |
| options | [UpdateSimMessageOptions](#updatesimmessageoptions7) | Yes | SIM message updating options.|
**Return value**
| Type | Description |
| ------------------- | ----------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let updateSimMessageOptions = {
slotId = 0,
msgIndex = 1,
newStatus = 0,
pdu = "xxxxxxx",
smsc = "test"
};
let promise = sms.updateSimMessage(updateSimMessageOptions);
promise.then(data => {
console.log(`updateSimMessage success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`updateSimMessage fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.getAllSimMessages<sup>7+</sup>
getAllSimMessages(slotId: number, callback: AsyncCallback<Array<SimShortMessage\>>): void
Obtains all SIM card messages. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------------------------------- | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| callback | AsyncCallback<Array<[SimShortMessage](#simshortmessage8)\>> | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
sms.getAllSimMessages(slotId, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.getAllSimMessages<sup>7+</sup>
getAllSimMessages(slotId: number): Promise<Array<SimShortMessage\>>
Obtains all SIM card messages. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
**Return value**
| Type | Description |
| ------------------------------------------------------- | ---------------------------------- |
| PromiseArray<[SimShortMessage](#simshortmessage8)\>&gt; | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let promise = sms.getAllSimMessages(slotId);
promise.then(data => {
console.log(`getAllSimMessages success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getAllSimMessages fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.setCBConfig<sup>7+</sup>
setCBConfig(options: CBConfigOptions, callback: AsyncCallback<void\>): void
Sets the cell broadcast configuration. This API uses an asynchronous callback to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------------------------------------ | ---- | ------------ |
| options | [CBConfigOptions](#cbconfigoptions8) | Yes | Cell broadcast configuration options.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Example**
```js
let cbConfigOptions = {
slotId = 0,
smsc = "test",
pdu = "xxxxxxxx",
status = 0
};
sms.setCBConfig(cbConfigOptions, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.setCBConfig<sup>7+</sup>
setCBConfig(options: CBConfigOptions): Promise<void\>
Sets the cell broadcast configuration. This API uses a promise to return the result.
This is a system API.
**Required permission**: ohos.permission.RECEIVE_SMS
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| ------- | ------------------------------------ | ---- | ------------ |
| options | [CBConfigOptions](#cbconfigoptions8) | Yes | Cell broadcast configuration options.|
**Return value**
| Type | Description |
| ------------------- | ----------------------------- |
| Promise&lt;void&gt; | Promise used to return the result.|
**Example**
```js
let cbConfigOptions = {
slotId = 0,
smsc = "test",
pdu = "xxxxxxxx",
status = 0
};
let promise = sms.setCBConfig(cbConfigOptions);
promise.then(data =>
console.log(`setCBConfig success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`setCBConfig fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.getSmsSegmentsInfo<sup>8+</sup>
getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean, callback: AsyncCallback<SmsSegmentsInfo\>): void
Obtains SMS message segment information. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------------------------------------------------------------ | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| message | string | Yes | SMS message. |
| force7bit | boolean | Yes | Whether to use 7-bit coding. |
| callback | AsyncCallback&lt;[SmsSegmentsInfo](#<smssegmentsinfo8)&gt; | Yes | Callback used to return the result. |
**Example**
```js
let slotId = 0;
sms.getSmsSegmentsInfo(slotId, "message", false, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.getSmsSegmentsInfo<sup>8+</sup>
getSmsSegmentsInfo(slotId: number, message: string, force7bit: boolean): Promise<SmsSegmentsInfo\>
Obtains SMS message segment information. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| --------- | ------- | ---- | ----------------------------------------- |
| slotId | number | Yes | SIM card slot ID. <br>- **0**: card slot 1<br>- **1**: card slot 2|
| message | string | Yes | Message |
| force7bit | boolean | Yes | Whether to use 7-bit coding. |
**Return value**
| Type | Description |
| ------------------------------------------------------- | ----------------------------- |
| Promise&lt;[SmsSegmentsInfo](#<smssegmentsinfo8)&gt; | Promise used to return the result.|
**Example**
```js
let slotId = 0;
let promise = sms.getSmsSegmentsInfo(slotId, "message", false);
promise.then(data =>
console.log(`getSmsSegmentsInfo success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getSmsSegmentsInfo fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.isImsSmsSupported<sup>8+</sup>
isImsSmsSupported(callback: AsyncCallback<boolean\>): void
Checks whether SMS is supported on IMS. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ---------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;boolean&gt; | Yes | Callback used to return the result.|
**Example**
```js
sms.isImsSmsSupported((err, data) => {
console.log(`callback: err->${JSON.(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.isImsSmsSupported<sup>8+</sup>
isImsSmsSupported(): Promise<boolean\>
Checks whether SMS is supported on IMS. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Return value**
| Type | Description |
| ---------------------- | ----------------------- |
| Promise&lt;boolean&gt; | Promise used to return the result.|
**Example**
```js
let promise = sms.isImsSmsSupported();
promise.then(data => {
console.log(`isImsSmsSupported success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`isImsSmsSupported fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.getImsShortMessageFormat<sup>8+</sup>
getImsShortMessageFormat(callback: AsyncCallback<string\>): void
Obtains the SMS format supported by the IMS. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | --------------------------- | ---- | ---------- |
| callback | AsyncCallback&lt;string&gt; | Yes | Callback used to return the result.|
**Example**
```js
sms.getImsShortMessageFormat((err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.getImsShortMessageFormat<sup>8+</sup>
getImsShortMessageFormat(): Promise<string\>
Obtains the SMS format supported by the IMS. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Return value**
| Type | Description |
| --------------------- | -------------------------- |
| Promise&lt;string&gt; | Promise used to return the result. |
**Example**
```js
let promise = sms.getImsShortMessageFormat();
promise.then(data => {
console.log(`getImsShortMessageFormat success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`getImsShortMessageFormat fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.decodeMms<sup>8+</sup>
decodeMms(mmsFilePathName: string | Array<number\>, callback: AsyncCallback<MmsInformation\>): void
Decodes MMS messages. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | ------------------------------------------------------- | ---- | -------------- |
| mmsFilePathName | string \|Array<number\> | Yes | MMS message file path.|
| callback | AsyncCallback&lt;[MmsInformation](#mmsinformation8)&gt; | Yes | Callback used to return the result. |
**Example**
```js
let mmsFilePathName = "filename";
sms.decodeMms(mmsFilePathName, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.decodeMms<sup>8+</sup>
decodeMms(mmsFilePathName: string | Array<number\>): Promise<MmsInformation\>
Decodes MMS messages. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| --------------- | ----------------------- | ---- | -------------- |
| mmsFilePathName | string \|Array<number\> | Yes | MMS message file path.|
**Return value**
| Type | Description |
| --------------------------------------------------------- | --------------------------- |
| Promise&lt;&lt;[MmsInformation](#mmsinformation8)&gt;&gt; | Promise used to return the result.|
**Example**
```js
let mmsFilePathName = "filename";
let promise = sms.getSmscAddr(mmsFilePathName);
promise.then(data => {
console.log(`decodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`decodeMms fail, promise: err->${JSON.stringify(err)}`);
});
```
## sms.encodeMms<sup>8+</sup>
encodeMms(mms: MmsInformation, callback: AsyncCallback<Array<number\>>): void
Encodes MMS messages. This API uses an asynchronous callback to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ----------------------------------- | ---- | ---------- |
| mms | [MmsInformation](#mmsinformation8) | Yes | MMS message information.|
| callback | AsyncCallback&lt;Array<number\>&gt; | Yes | Callback used to return the result.|
**Example**
```js
let mmsAcknowledgeInd = {
transactionId = "100",
version = 0x10,
reportAllowed = 128
};
let mmsInformation = {
messageType = 133,
mmsType = mmsAcknowledgeInd
};
sms.encodeMms(mmsInformation, (err, data) => {
console.log(`callback: err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`);
});
```
## sms.encodeMms<sup>8+</sup>
encodeMms(mms: MmsInformation): Promise<Array<number\>>
Encodes MMS messages. This API uses a promise to return the result.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ---------------------------------- | ---- | ---------- |
| mms | [MmsInformation](#mmsinformation8) | Yes | MMS message information.|
**Return value**
| Type | Description |
| ----------------------------- | ----------------------------------- |
| Promise&lt;Array<number\>&gt; | Promise used to return the result.|
**Example**
```js
let mmsAcknowledgeInd = {
transactionId = "100",
version = 0x10,
reportAllowed = 128
};
let mmsInformation = {
messageType = 133,
mmsType = mmsAcknowledgeInd
};
let promise = sms.encodeMms(mmsInformation);
promise.then(data => {
console.log(`encodeMms success, promise: data->${JSON.stringify(data)}`);
}).catch(err => {
console.error(`encodeMms fail, promise: err->${JSON.stringify(err)}`);
});
```
## ShortMessage ## ShortMessage
Defines an SMS message instance. Defines an SMS message instance.
...@@ -383,7 +1116,7 @@ Defines an SMS message instance. ...@@ -383,7 +1116,7 @@ Defines an SMS message instance.
| Name | Type | Description | | Name | Type | Description |
| ------------------------ | --------------------------------------- | ------------------------------------------------------------ | | ------------------------ | --------------------------------------- | ------------------------------------------------------------ |
| hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>TP-Reply-Path: The device returns a response based on the SMSC that sends the SMS message.| | hasReplyPath | boolean | Whether the received SMS contains **TP-Reply-Path**. The default value is **false**.<br>**TP-Reply-Path**: The device returns a response based on the SMSC that sends the SMS message.|
| isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.| | isReplaceMessage | boolean | Whether the received SMS message is a **replace short message**. The default value is **false**.<br>For details, see section 9.2.3.9 in **3GPP TS 23.040**.|
| isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.| | isSmsStatusReportMessage | boolean | Whether the received SMS message is an SMS delivery status report. The default value is **false**.<br>**SMS-Status-Report**: a message sent from the SMSC to the mobile station to show the SMS message delivery status.|
| messageClass | [ShortMessageClass](#shortmessageclass) | Enumerates SMS message types. | | messageClass | [ShortMessageClass](#shortmessageclass) | Enumerates SMS message types. |
...@@ -464,3 +1197,422 @@ Enumerates SMS message sending results. ...@@ -464,3 +1197,422 @@ Enumerates SMS message sending results.
| SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to an unknown reason. | | SEND_SMS_FAILURE_UNKNOWN | 1 | Failed to send the SMS message due to an unknown reason. |
| SEND_SMS_FAILURE_RADIO_OFF | 2 | Failed to send the SMS message because the modem is shut down. | | SEND_SMS_FAILURE_RADIO_OFF | 2 | Failed to send the SMS message because the modem is shut down. |
| SEND_SMS_FAILURE_SERVICE_UNAVAILABLE | 3 | Failed to send the SMS message because the network is unavailable or SMS message sending or receiving is not supported.| | SEND_SMS_FAILURE_SERVICE_UNAVAILABLE | 3 | Failed to send the SMS message because the network is unavailable or SMS message sending or receiving is not supported.|
## MmsInformation<sup>8+</sup>
Defines the MMS message information.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ----------- | ------------------------------------------------------------ | ---- | --------- |
| messageType | [MessageType](#messagetype8) | Yes | Message type. |
| mmsType | [MmsSendReq](#mmssendreq8) \|[MmsSendConf](#mmssendconf8) \|[MmsNotificationInd](#mmsnotificationind8) \|[MmsRespInd](#mmsrespind8) \|[MmsRetrieveConf](#mmsretrieveconf8)\|[MmsAcknowledgeInd](#mmsacknowledgeind8)\|[MmsDeliveryInd](#mmsdeliveryind8)\|[MmsReadOrigInd](#mmsreadorigind8)\|[MmsReadRecInd](#mmsreadrecind8)| Yes | PDU header type.|
| attachment | Array<[MmsAttachment](#mmsattachment8)\> | No | Attachment. |
## MmsSendReq<sup>8+</sup>
Defines an MMS message sending request.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ---------------- | ------------------------------------ | ---- | ------------ |
| from | [MmsAddress](#mmsaddress8) | Yes | MMS message source. |
| transactionId | string | Yes | Transaction ID. |
| contentType | string | Yes | Content type. |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
| to | Array<[MmsAddress](#mmsaddress8)\> | No | Address to which the message is sent. |
| date | number | No | Date. |
| cc | Array<[MmsAddress](#mmsaddress8)\> | No | Carbon copy. |
| bcc | Array<[MmsAddress](#mmsaddress8)\> | No | Blind carbon copy. |
| subject | string | No | Subject. |
| messageClass | number | No | Message class. |
| expiry | number | No | Expiration. |
| priority | [MmsPriorityType](#mmsprioritytype8) | No | Priority. |
| senderVisibility | number | No | Sender visibility.|
| deliveryReport | number | No | Delivery report. |
| readReport | number | No | Read report. |
## MmsSendConf<sup>8+</sup>
Defines the MMS message sending configuration.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ------------- | ---------------------------------- | ---- | -------- |
| responseState | number | Yes | Response status.|
| transactionId | string | Yes | Transaction ID. |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
| messageId | string | No | Message ID. |
## MmsNotificationInd<sup>8+</sup>
Defines an MMS notification index.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| --------------- | ---------------------------------- | ---- | -------- |
| transactionId | string | Yes | Transaction ID. |
| messageClass | number | Yes | Message class. |
| messageSize | number | Yes | Message size.|
| expiry | number | Yes | Expiration. |
| contentLocation | string | Yes | Content location.|
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
| from | [MmsAddress](#mmsaddress8) | No | Source. |
| subject | string | No | Subject. |
| deliveryReport | number | No | Status report.|
| contentClass | number | No | Content class. |
## MmsAcknowledgeInd<sup>8+</sup>
Defines an MMS confirmation index.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ------------- | ---------------------------------- | ---- | -------- |
| transactionId | string | Yes | Transaction ID. |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
| reportAllowed | [ReportType](#reporttype8) | No | Report allowed.|
## MmsRetrieveConf<sup>8+</sup>
Defines the MMS message retrieval configuration.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| -------------- | ------------------------------------ | ---- | -------- |
| transactionId | string | Yes | Transaction ID. |
| messageId | string | Yes | Message ID. |
| date | number | Yes | Date. |
| contentType | string | Yes | Content type.|
| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Address to which the message is sent. |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version |
| from | [MmsAddress](#mmsaddress8) | No | Source. |
| cc | Array<[MmsAddress](#mmsaddress8)\> | No | Carbon copy. |
| subject | string | No | Subject. |
| priority | [MmsPriorityType](#mmsprioritytype8) | No | Priority. |
| deliveryReport | number | No | Status report.|
| readReport | number | No | Read report.|
| retrieveStatus | number | No | Retrieval status.|
| retrieveText | string | No | Retrieval text.|
## MmsReadOrigInd<sup>8+</sup>
Defines the original MMS message reading index.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ---------- | ---------------------------------- | ---- | -------- |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
| messageId | string | Yes | Message ID. |
| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Address to which the message is sent. |
| from | [MmsAddress](#mmsaddress8) | Yes | Source. |
| date | number | Yes | Date. |
| readStatus | number | Yes | Read status.|
## MmsAttachment<sup>8+</sup>
Defines the attachment of an MMS message.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ----------------------- | ------------------------------------ | ---- | ------------------ |
| contentId | string | Yes | Content ID. |
| contentLocation | string | Yes | Content location. |
| contentDisposition | [DispositionType](#dispositiontype8) | Yes | Content disposition. |
| contentTransferEncoding | string | Yes | Encoding for content transfer. |
| contentType | string | Yes | Content type. |
| isSmil | boolean | Yes | Whether the synchronized multimedia integration language is used.|
| path | string | No | Path. |
| inBuff | Array<number\> | No | In the buffer |
| fileName | string | No | File name. |
| charset | [MmsCharSets](#mmscharsets8) | No | Character set. |
## MmsAddress<sup>8+</sup>
Defines an MMSC address.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ------- | ---------------------------- | ---- | ------ |
| address | string | Yes | MMSC address. |
| charset | [MmsCharSets](#mmscharsets8) | Yes | Character set.|
## MessageType<sup>8+</sup>
Enumerates message types.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description |
| ------------------------- | ---- | -------------------- |
| TYPE_MMS_SEND_REQ | 128 | MMS message sending request. |
| TYPE_MMS_SEND_CONF | 129 | MMS message sending configuration. |
| TYPE_MMS_NOTIFICATION_IND | 130 | MMS notification index. |
| TYPE_MMS_RESP_IND | 131 | MMS message response index. |
| TYPE_MMS_RETRIEVE_CONF | 132 | MMS message retrieval configuration. |
| TYPE_MMS_ACKNOWLEDGE_IND | 133 | MMS message acknowledgement index. |
| TYPE_MMS_DELIVERY_IND | 134 | MMS message delivery index. |
| TYPE_MMS_READ_REC_IND | 135 | MMS message reading and receiving index.|
| TYPE_MMS_READ_ORIG_IND | 136 | Original MMS message reading index.|
## MmsPriorityType<sup>8+</sup>
Enumerates MMS message priorities.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description |
| ---------- | ---- | -------------- |
| MMS_LOW | 128 | Low priority. |
| MMS_NORMAL | 129 | Normal priority.|
| MMS_HIGH | 130 | High priority. |
## MmsVersionType<sup>8+</sup>
Enumerates MMS versions.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description |
| --------------- | ---- | ----------- |
| MMS_VERSION_1_0 | 0x10 | MMS version 1_0.|
| MMS_VERSION_1_1 | 0x11 | MMS version 1_1.|
| MMS_VERSION_1_2 | 0x12 | MMS version 1_2.|
| MMS_VERSION_1_3 | 0x13 | MMS version 1_3.|
## MmsCharSets<sup>8+</sup>
Enumerates MMS character sets.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description |
| --------------- | ------ | ------------------- |
| BIG5 | 0X07EA | BIG5 format. |
| ISO_10646_UCS_2 | 0X03E8 | ISO_10646_UCS_2 format.|
| ISO_8859_1 | 0X04 | ISO_8859_1 format. |
| ISO_8859_2 | 0X05 | ISO_8859_2 format. |
| ISO_8859_3 | 0X06 | ISO_8859_3 format. |
| ISO_8859_4 | 0X07 | ISO_8859_4 format. |
| ISO_8859_5 | 0X08 | ISO_8859_5 format. |
| ISO_8859_6 | 0X09 | ISO_8859_6 format. |
| ISO_8859_7 | 0X0A | ISO_8859_7 format. |
| ISO_8859_8 | 0X0B | ISO_8859_8 format. |
| ISO_8859_9 | 0X0C | ISO_8859_9 format. |
| SHIFT_JIS | 0X11 | SHIFT_JIS format. |
| US_ASCII | 0X03 | US_ASCII format. |
| UTF_8 | 0X6A | UTF_8 format. |
## DispositionType<sup>8+</sup>
Enumerates disposition types.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description |
| ---------- | ---- | -------- |
| FROM_DATA | 0 | Data source.|
| ATTACHMENT | 1 | Attachment. |
| INLINE | 2 | Inlining. |
## ReportType<sup>8+</sup>
Enumerates report types.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description|
| ------- | ---- | ---- |
| MMS_YES | 128 | YES |
| MMS_NO | 129 | NO |
## CBConfigOptions<sup>8+</sup>
Defines the cell broadcast configuration options.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| -------------- | -------------------- | ---- | ------------ |
| slotId | number | Yes | Card slot ID. |
| enable | boolean | Yes | Whether to enable cell broadcast. |
| startMessageId | number | Yes | Start message ID. |
| endMessageId | number | Yes | End message ID. |
| ranType | [RanType](#rantype7) | Yes | RAN type.|
## SimMessageStatus<sup>7+</sup>
Defines the SIM message status.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description |
| ------------------------- | ---- | --------------------------- |
| SIM_MESSAGE_STATUS_FREE | 0 | Free state. |
| SIM_MESSAGE_STATUS_READ | 1 | Read state. |
| SIM_MESSAGE_STATUS_UNREAD | 3 | Unread state. |
| SIM_MESSAGE_STATUS_SENT | 5 | Storage of sent messages (applicable only to SMS).|
| SIM_MESSAGE_STATUS_UNSENT | 7 | Storage of unsent messages (applicable only to SMS).|
## RanType<sup>7+</sup>
Enumerates RAN types.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description|
| --------- | ---- | ---- |
| TYPE_GSM | 1 | GSM |
| TYPE_CDMA | 2 | CMDA |
## SmsEncodingScheme<sup>8+</sup>
Enumerates SMS encoding schemes.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Value | Description |
| -------------------- | ---- | ------------ |
| SMS_ENCODING_UNKNOWN | 0 | Unknown code.|
| SMS_ENCODING_7BIT | 1 | 7-digit code. |
| SMS_ENCODING_8BIT | 2 | 8-digit code. |
| SMS_ENCODING_16BIT | 3 | 16-digit code.|
## SimMessageOptions<sup>7+</sup>
Defines the SIM message options.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name| Type | Mandatory| Description |
| ------ | -------------------------------------- | ---- | -------------- |
| slotId | number | Yes | Card slot ID. |
| smsc | string | Yes | Short message service center.|
| pdu | string | Yes | Protocol data unit. |
| status | [SimMessageStatus](#simmessagestatus7) | Yes | Message status. |
## UpdateSimMessageOptions<sup>7+</sup>
Defines the updating SIM message options.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| --------- | -------------------------------------- | ---- | -------------- |
| slotId | number | Yes | Card slot ID. |
| msgIndex | number | Yes | Message index. |
| newStatus | [SimMessageStatus](#simmessagestatus7) | Yes | New status. |
| pdu | string | Yes | Protocol data unit. |
| smsc | string | Yes | Short message service center.|
## SimShortMessage<sup>8+</sup>
Defines a SIM message.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ---------------- | -------------------------------------- | ---- | ------------- |
| shortMessage | [ShortMessage](#shortmessage) | Yes | SMS message. |
| simMessageStatus | [SimMessageStatus](#simmessagestatus7) | Yes | SIM message status.|
| indexOnSim | number | Yes | SIM card index. |
## MmsDeliveryInd<sup>8+</sup>
Defines an MMS message delivery index.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| --------- | ---------------------------------- | ---- | ------ |
| messageId | string | Yes | Message ID.|
| date | number | Yes | Date. |
| to | Array<[MmsAddress](#mmsaddress8)\> | Yes | Address to which the message is sent.|
| status | number | Yes | Status. |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
## MmsRespInd<sup>8+</sup>
Defines an MMS response index.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| ------------- | ---------------------------------- | ---- | -------- |
| transactionId | string | Yes | Event ID. |
| status | number | Yes | Status. |
| version | [MmsVersionType](#mmsversiontype8) | Yes | Version. |
| reportAllowed | [ReportType](#reporttype8) | No | Report allowed.|
## SmsSegmentsInfo<sup>8+</sup>
Defines the SMS message segment information.
This is a system API.
**System capability**: SystemCapability.Telephony.SmsMms
| Name | Type | Mandatory| Description |
| -------------------- | ---------------------------------------- | ---- | ------------ |
| splitCount | number | Yes | Split count. |
| encodeCount | number | Yes | Encoding count. |
| encodeCountRemaining | number | Yes | Remaining encoding count.|
| scheme | [SmsEncodingScheme](#smsencodingscheme8) | Yes | Encoding scheme.|
# USB # USB
> **NOTE**<br> This module provides USB device management functions, including USB device list query, bulk data transfer, control transfer, and permission control.
> **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 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 ## Modules to Import
...@@ -23,6 +26,7 @@ Obtains the USB device list. ...@@ -23,6 +26,7 @@ Obtains the USB device list.
| Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list. | | Array&lt;Readonly&lt;[USBDevice](#usbdevice)&gt;&gt; | Device information list. |
- **Example** - **Example**
```js ```js
let devicesList = usb.getDevices(); let devicesList = usb.getDevices();
console.log(`devicesList = ${JSON.stringify(devicesList)}`); console.log(`devicesList = ${JSON.stringify(devicesList)}`);
...@@ -90,16 +94,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -90,16 +94,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| device | [USBDevice](#usbdevice) | Yes| USB device information. | | device | [USBDevice](#usbdevice) | Yes| USB device information. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer. | | Readonly&lt;[USBDevicePipe](#usbdevicepipe)&gt; | USB device pipe for data transfer. |
- **Example** - **Example**
```js ```js
let devicepipe= usb.connectDevice(device); let devicepipe= usb.connectDevice(device);
console.log(`devicepipe = ${JSON.stringify(devicepipe)}`); console.log(`devicepipe = ${JSON.stringify(devicepipe)}`);
...@@ -115,16 +122,19 @@ Checks whether the application has the permission to access the device. ...@@ -115,16 +122,19 @@ Checks whether the application has the permission to access the device.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name. | | deviceName | string | Yes| Device name. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise. | | boolean | Returns **true** if the application has the permission to access the device; returns **false** otherwise. |
- **Example** - **Example**
```js ```js
let devicesName="1-1"; let devicesName="1-1";
let bool = usb.hasRight(devicesName); let bool = usb.hasRight(devicesName);
...@@ -141,16 +151,19 @@ Requests the temporary permission for the application to access the USB device. ...@@ -141,16 +151,19 @@ Requests the temporary permission for the application to access the USB device.
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| deviceName | string | Yes| Device name. | | deviceName | string | Yes| Device name. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise. | | Promise&lt;boolean&gt; | Returns **true** if the temporary device access permissions are granted; returns **false** otherwise. |
- **Example** - **Example**
```js ```js
let devicesName="1-1"; let devicesName="1-1";
usb.requestRight(devicesName).then((ret) => { usb.requestRight(devicesName).then((ret) => {
...@@ -169,6 +182,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -169,6 +182,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. |
...@@ -176,11 +190,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -176,11 +190,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
| force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface. | | force | boolean | No| Whether to forcibly claim the USB interface. The default value is **false**, indicating not to forcibly claim the USB interface. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise. | | number | Returns **0** if the USB interface is successfully claimed; returns an error code otherwise. |
- **Example** - **Example**
```js ```js
let ret = usb.claimInterface(devicepipe, interfaces); let ret = usb.claimInterface(devicepipe, interfaces);
console.log(`claimInterface = ${ret}`); console.log(`claimInterface = ${ret}`);
...@@ -198,17 +214,20 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c ...@@ -198,17 +214,20 @@ Before you do this, ensure that you have claimed the interface by calling [usb.c
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. |
| iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release. | | iface | [USBInterface](#usbinterface) | Yes| USB interface, which is used to determine the index of the interface to release. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB interface is successfully released; returns an error code otherwise. | | number | Returns **0** if the USB interface is successfully released; returns an error code otherwise. |
- **Example** - **Example**
```js ```js
let ret = usb.releaseInterface(devicepipe, interfaces); let ret = usb.releaseInterface(devicepipe, interfaces);
console.log(`releaseInterface = ${ret}`); console.log(`releaseInterface = ${ret}`);
...@@ -226,17 +245,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -226,17 +245,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. |
| config | [USBConfig](#usbconfig) | Yes| USB configuration to set. | | config | [USBConfig](#usbconfig) | Yes| USB configuration to set. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise. | | number | Returns **0** if the USB configuration is successfully set; returns an error code otherwise. |
- **Example** - **Example**
```js ```js
let ret = usb.setConfiguration(devicepipe, config); let ret = usb.setConfiguration(devicepipe, config);
console.log(`setConfiguration = ${ret}`); console.log(`setConfiguration = ${ret}`);
...@@ -253,17 +275,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -253,17 +275,20 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. |
| iface | [USBInterface](#usbinterface) | Yes| USB interface to set. | | iface | [USBInterface](#usbinterface) | Yes| USB interface to set. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB interface is successfully set; returns an error code otherwise. | | number | Returns **0** if the USB interface is successfully set; returns an error code otherwise. |
- **Example** - **Example**
```js ```js
let ret = usb.setInterface(devicepipe, interfaces); let ret = usb.setInterface(devicepipe, interfaces);
console.log(`setInterface = ${ret}`); console.log(`setInterface = ${ret}`);
...@@ -281,16 +306,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -281,16 +306,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Uint8Array | Raw descriptor data. The value **undefined** indicates that the operation has failed. | | Uint8Array | Raw descriptor data. The value **undefined** indicates that the operation has failed. |
- **Example** - **Example**
```js ```js
let ret = usb.getRawDescriptor(devicepipe); let ret = usb.getRawDescriptor(devicepipe);
``` ```
...@@ -307,16 +335,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -307,16 +335,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| Device pipe, which is used to determine the bus number and device address. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | File descriptor of the USB device. The value **-1** indicates that the operation has failed. | | number | File descriptor of the USB device. The value **-1** indicates that the operation has failed. |
- **Example** - **Example**
```js ```js
let ret = usb.getFileDescriptor(devicepipe); let ret = usb.getFileDescriptor(devicepipe);
``` ```
...@@ -333,6 +364,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -333,6 +364,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device. |
...@@ -340,11 +372,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -340,11 +372,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout. | | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. | | Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. |
- **Example** - **Example**
```js ```js
usb.controlTransfer(devicepipe, USBControlParams).then((ret) => { usb.controlTransfer(devicepipe, USBControlParams).then((ret) => {
console.log(`controlTransfer = ${JSON.stringify(ret)}`); console.log(`controlTransfer = ${JSON.stringify(ret)}`);
...@@ -363,6 +397,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -363,6 +397,7 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe, which is used to determine the USB device. |
...@@ -371,11 +406,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -371,11 +406,13 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
| timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout. | | timeout | number | No| Timeout duration. The default value is **0**, indicating no timeout. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. | | Promise&lt;number&gt; | Returns the size of the transmitted or received data block if the control transfer is successful; returns **-1** if an exception occurs. |
- **Example** - **Example**
```js ```js
// Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission. // Call usb.getDevices to obtain a data set. Then, obtain a USB device and its access permission.
// Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device. // Pass the obtained USB device as a parameter to usb.connectDevice. Then, call usb.connectDevice to connect the USB device.
...@@ -397,16 +434,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi ...@@ -397,16 +434,19 @@ Before you do this, call [usb.getDevices](#usbgetdevices) to obtain the USB devi
**System capability**: SystemCapability.USB.USBManager **System capability**: SystemCapability.USB.USBManager
- **Parameters** - **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe. | | pipe | [USBDevicePipe](#usbdevicepipe) | Yes| USB device pipe. |
- **Return value** - **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise. | | number | Returns **0** if the USB device pipe is closed successfully; returns an error code otherwise. |
- **Example** - **Example**
```js ```js
let ret = usb.closePipe(devicepipe); let ret = usb.closePipe(devicepipe);
console.log(`closePipe = ${ret}`); console.log(`closePipe = ${ret}`);
...@@ -553,3 +593,68 @@ Enumerates request directions. ...@@ -553,3 +593,68 @@ Enumerates request directions.
| -------- | -------- | -------- | | -------- | -------- | -------- |
| USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device. | | USB_REQUEST_DIR_TO_DEVICE | 0 | Request for writing data from the host to the device. |
| USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host. | | USB_REQUEST_DIR_FROM_DEVICE | 0x80 | Request for reading data from the device to the host. |
## FunctionType<sup>9+</sup>
Enumerates function types for the USB device.
This is a system API.
**System capability**: SystemCapability.USB.USBManager
| Name | Value | Description |
| ------------ | ---- | ---------- |
| NONE | 0 | No function.|
| ACM | 1 | ACM function. |
| ECM | 2 | ECM function. |
| HDC | 4 | HDC function. |
| MTP | 8 | Not supported currently.|
| PTP | 16 | Not supported currently.|
| RNDIS | 32 | Not supported currently.|
| MIDI | 64 | Not supported currently.|
| AUDIO_SOURCE | 128 | Not supported currently.|
| NCM | 256 | Not supported currently.|
## PortModeType<sup>9+</sup>
Enumerates USB port mode types.
This is a system API.
**System capability**: SystemCapability.USB.USBManager
| Name | Value | Description |
| --------- | ---- | ---------------------------------------------------- |
| NONE | 0 | None. |
| UFP | 1 | Upstream facing port, which functions as the sink of power supply. |
| DFP | 2 | Downstream facing port, which functions as the source of power supply. |
| DRP | 3 | Dynamic reconfiguration port (DRP), which can function as the DFP (host) or UFP (device). It is not supported currently.|
| NUM_MODES | 4 | Not supported currently. |
## PowerRoleType<sup>9+</sup>
Enumerates power role types.
This is a system API.
**System capability**: SystemCapability.USB.USBManager
| Name | Value | Description |
| ------ | ---- | ---------- |
| NONE | 0 | None. |
| SOURCE | 1 | External power supply.|
| SINK | 2 | Internal power supply.|
## DataRoleType<sup>9+</sup>
Enumerates data role types.
This is a system API.
**System capability**: SystemCapability.USB.USBManager
| Name | Value | Description |
| ------ | ---- | ------------ |
| NONE | 0 | None. |
| HOST | 1 | USB host.|
| DEVICE | 2 | USB device.|
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册