openharmony_ci 2327cba6f4 !550 merge master into master
fix HandleCallbackInfoUpdate memery leak

Created-by: hcwww
Commit-by: hcwww
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)
https://gitcode.com/openharmony/telephony_state_registry/issues/256


### 二、建议测试周期和提测地址  
  建议测试完成时间:xxxx.xx.xx  
  投产上线时间:xxxx.xx.xx  
  提测地址:CI环境/压测环境  
  测试账号:  

### 三、变更内容
  * 3.1 关联PR列表

  * 3.2 数据库和部署说明  
    1. 常规更新 
    2. 重启unicorn
    3. 重启sidekiq
    4. 迁移任务:是否有迁移任务,没有写 "无"
    5. rake脚本:`bundle exec xxx RAILS_ENV = production`;没有写 "无"

  * 3.4 其他技术优化内容(做了什么,变更了什么)
    - 修复ffi层HandleCallbackInfoUpdate内存泄漏


  * 3.5 废弃通知(什么字段、方法弃用?)



  * 3.6  后向不兼容变更(是否有无法向后兼容的变更?)


  
### 四、研发自测点(自测哪些?冒烟用例全部自测?)
  自测测试结论:


### 五、测试关注点(需要提醒QA重点关注的、可能会忽略的地方)
  检查点:

| 需求名称 | 是否影响xx公共模块 | 是否需要xx功能 | 需求升级是否依赖其他子产品 |
|------|------------|----------|---------------|
| xxx  | 否          | 需要       | 不需要           |
|      |            |          |               |

  接口测试:

  性能测试:

  并发测试:

  其他:



See merge request: openharmony/telephony_state_registry!550
2026-06-03 17:37:25 +08:00
2022-03-29 11:31:44 +08:00
2026-06-03 17:37:25 +08:00
2026-02-09 19:35:54 +08:00
2026-02-09 19:35:54 +08:00
2025-07-23 10:32:25 +08:00
2025-10-11 10:56:20 +08:00
2025-09-28 16:15:45 +08:00
2022-03-29 11:31:44 +08:00
2023-04-25 13:53:25 +08:00
2022-12-01 14:43:12 +08:00

State Registry

Introduction

The state registry module provides APIs to register and deregister an observer that listens for various callback events of the telephony subsystem. Such events include but are not limited to the following: network status change, signal strength change, cell information change, cellular data connection status change, and call status change.

Figure 1 Architecture of the state registry module

Directory Structure

/base/telephony/state_registry      # State registry service
├─ figures                          # Figures of readme files
├─ frameworks                       # Framework layer
│  ├─ js                            # JS code
│  └─ native                        # Native code
├─ interfaces                       # APIs
│  ├─ innerkits                     # Internal APIs
│  └─ kits                          # External APIs \(such as JS APIs\)
├─ sa_profile                       # SA profile
├─ services                         # Service code
└─ test                             # Test code
   ├─ mock                          # Simulation test
   └─ unittest                      # Unit test

Constraints

  • Programming language: JavaScript
  • Software constraints: this service needs to work with the telephony core service (core_service).
  • Hardware constraints: the accommodating device must be equipped with a modem and a SIM card capable of independent cellular communication.
  • The API for registering an observer for the SIM card status takes effect only when SIM cards are in position. If SIM cards are removed, no callback events will be received. Your application can call the getSimState API to check whether SIM cards are in position.

Usage

Available APIs

Table 1 Registration APIs

API Description
function on(type: String, options: { slotId?: number }, callback: AsyncCallback<T>): void; Registers an observer.
function off(type: String, callback?: AsyncCallback<T>): void; Deregisters an observer.

Usage Guidelines

Parameters of C APIs

Different subscription events are distinguished by the type parameter. The following table lists the related type parameters.

Table 2 Description of type parameters

Parameter Description Required Permission
networkStateChange Network status change event ohos.permission.GET_NETWORK_INFO
signalInfoChange Signal change event None
cellInfoChange Cell information change event ohos.permission.LOCATION and ohos.permission.APPROXIMATELY_LOCATION
cellularDataConnectionStateChange Cellular data connection status change event None
cellularDataFlowChange Cellular data flow change event None
callStateChange Call status change event, in which the value of phoneNumber is empty if the user does not have the required permission. ohos.permission.READ_CALL_LOG
simStateChange SIM card status change event None

Sample Code

The function of registering an observer for call status change events is used as an example. The process is as follows:

  1. Call the on method with the type parameter specified to register an observer for different types of events.

  2. Check whether the registration is successful. If err is empty in the received callback, the registration is successful. If err is not empty, the registration has failed. Obtain the required data from value if the registration is successful.

  3. Call the off method to deregister the observer. After the observer is deregistered, no callback will be received.

    // Import the observer package.
    import observer from '@ohos.telephony.observer';
    
    // Registers an observer.
    observer.on('callStateChange', {slotId: 1}, (err, value) => {
      if (err) {
        // If the API call failed, err is not empty.
        console.error(`failed, because ${err.message}`);
        return;
      }
      // If the API call succeeded, err is empty.
      console.log(`success on. number is ` + value.number + ", state is " + value.state);
    });
    
    // Deregister the observer.
    observer.off('callStateChange', (err, value) => {
      if (err) {
        // If the API call failed, err is not empty.
        console.error(`failed, because ${err.message}`);
        return;
      }
      // If the API call succeeded, err is empty.
      console.log(`success off`);
    });
    

Repositories Involved

Telephony

telephony_state_registry

telephony_core_service

telephony_cellular_data

telephony_cellular_call

telephony_call_manager

S
Description
暂无描述
Readme 5 MiB
Languages
C++ 89.3%
Rust 10.1%
C 0.6%