!34 merge master into master

fix createSubcriber error

Created-by: jiao_yang
Commit-by: JIAO
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)



### 二、建议测试周期和提测地址  
  建议测试完成时间: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 其他技术优化内容(做了什么,变更了什么)
    - 重构了 xxxx 代码
    - xxxx 算法优化


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



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


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


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

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

  接口测试:

  性能测试:

  并发测试:

  其他:



See merge request: openharmony/notification_notification_cangjie_wrapper!34
This commit is contained in:
openharmony_ci
2025-11-05 14:18:51 +08:00
3 changed files with 10 additions and 4 deletions
@@ -21,6 +21,7 @@ import ohos.labels.APILevel
import ohos.ffi.{Callback1Param, INVALID_CODE}
import ohos.common_event_data.CCommonEventData
import ohos.common_event_publish_data.CCommonEventPublishData
import ohos.common_event_subscribe_info.CSubscribeInfo
import ohos.business_exception.{BusinessException, AsyncCallback}
public import ohos.common_event_data.CommonEventData
public import ohos.common_event_publish_data.CommonEventPublishData
@@ -75,12 +76,15 @@ public class CommonEventManager {
syscap: "SystemCapability.Notification.CommonEvent"
]
public static func createSubscriber(subscribeInfo: CommonEventSubscribeInfo): CommonEventSubscriber {
let ret = unsafe { CJ_CreateSubscriber(0) }
if (ret == Int64(INVALID_CODE)) {
var errorCode: Int32 = 0
var info = CSubscribeInfo(subscribeInfo)
let id = unsafe { FfiCommonEventManagerCreateSubscriber(inout info, inout errorCode) }
info.free()
if (errorCode == INVALID_CODE) {
throw BusinessException(getErrorCode(ERROR_CES_UNINITIALIZED),
"CommonEventManager: createSubscriber failed: ${getErrorMsg(ERROR_CES_UNINITIALIZED)}")
}
return CommonEventSubscriber(ret)
return CommonEventSubscriber(id)
}
/**
@@ -34,5 +34,7 @@ foreign {
func CJ_Subscribe(id: Int64, funcId: Int64): Int32
func CJ_Unsubscribe(id: Int64): Int32
func FfiCommonEventManagerCreateSubscriber(info: CPointer<CSubscribeInfo>, errorCode: CPointer<Int32>): Int64
}
@@ -43,7 +43,7 @@ protected struct CSubscribeInfo {
publisherPermission = LibC.mallocCString(info.publisherPermission)
publisherDeviceId = LibC.mallocCString(info.publisherDeviceId)
publisherBundleName = LibC.mallocCString(info.publisherBundleName)
} catch(e: BusinessException) {
} catch(e: Exception) {
LibC.free(publisherPermission)
LibC.free(publisherDeviceId)
LibC.free(publisherBundleName)