945 Commits

Author SHA1 Message Date
g00586423 ffe2be4520 输入不足告警整改-问题-SA发通知失败
Co-Authored-By: Agent
Signed-off-by: g00586423 <guxiang11@huawei.com>
2026-08-23 18:20:03 +08:00
openharmony_ci 511aa556b6 !4924 merge master into master
输入不足告警整改

Created-by: lx180327070811
Commit-by: g00586423
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_distributed_notification_service!4924
2026-08-23 11:33:29 +08:00
g00586423 641224f6db 输入不足告警整改
Signed-off-by: g00586423 <guxiang11@huawei.com>
2026-08-23 10:13:05 +08:00
xdongs2009 99b66ae400 AI检视意见修复 Co-Authored-By:Agent
Signed-off-by: xdongs2009 <xdongs@163.com>
2026-08-22 10:06:32 +08:00
hanwenhui 36699a8655 Co-Authored-By: hanwenhui
Signed-off-by: hanwenhui <hanwenhui2@h-partners.com>
2026-08-13 11:29:23 +08:00
openharmony_ci 5d05d8785c !4962 merge master into master
BTI使能 Co-Authored-By:xdongs2009

Created-by: xdongs2009
Commit-by: xdongs2009
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_distributed_notification_service!4962
2026-08-08 17:39:39 +08:00
openharmony_ci 2fc45d841d !4960 merge fix/mst-db-isolation into master
fix(ans): fix cross-SO singleton issue by adding AnsNotification::GetInstance()

Created-by: cheerful_ricky
Commit-by: CheerfulRicky
Merged-by: openharmony_ci
Description: ## Problem

`DelayedSingleton<AnsNotification>::GetInstance()` returns different singleton objects in different shared libraries because the template's static members (`instance_`, `mutex_`) have vague linkage (COMDAT) and are hidden per-SO by `-fvisibility=hidden` + version scripts.

## Solution

1. **Add `AnsNotification::GetInstance()`** using function-local static (C++11 thread-safe, defined out-of-line in `ans_notification.cpp` within `libans_innerkits`, symbol exported via `*Ans*` in `.map`)
2. **Replace ALL callers** (NAPI/ANI/Tools/Tests/CJ FFI) from `DelayedSingleton<AnsNotification>::GetInstance()` to `AnsNotification::GetInstance()`
3. **Clean up** `#include singleton.h` from files that no longer use `DelayedSingleton` (kept in `ans_manager_death_recipient.h` and `pixelmap_cache_manager.h` which still use `DelayedSingleton` as base class)

## Why it works

The function-local static in `ans_notification.cpp` lives in `libans_innerkits.so`'s data segment. `AnsNotification::GetInstance()` is a non-inline member function compiled only in `libans_innerkits.so` and exported via `*Ans*` pattern in `libans_innerkits.map`. All SOs call this exported function through dynamic linking, sharing the single instance.

## Verification

Syntax-checked key files with exact ninja build flags: `ans_notification.cpp`, `notification_helper.cpp`, `ans_manager_death_recipient.cpp`, `napi_cancel.cpp`, `ani_cance.cpp`, `notification_manager_impl.cpp` (CJ FFI), `notification_shell_command.cpp` (Tools) — all passed.

Co-Authored-By: Agent

See merge request: openharmony/notification_distributed_notification_service!4960
2026-08-08 16:30:13 +08:00
xdongs2009 c4fe4a0e2d BTI使能 Co-Authored-By:xdongs2009
Signed-off-by: xdongs2009 <xdongs@163.com>
2026-08-08 08:41:18 +08:00
CheerfulRicky dfb21d3fcf fix(ans): fix cross-SO singleton issue by adding AnsNotification::GetInstance()
DelayedSingleton<AnsNotification>::GetInstance() returns different
singleton objects in different shared libraries because the template's
static members (instance_, mutex_) have vague linkage (COMDAT) and are
hidden per-SO by -fvisibility=hidden + version scripts.

Solution:
1. Add AnsNotification::GetInstance() using function-local static
   (C++11 thread-safe, defined out-of-line in ans_notification.cpp
   within libans_innerkits, symbol exported via *Ans* in .map)
2. Replace ALL callers (NAPI/ANI/Tools/Tests/CJ FFI) from
   DelayedSingleton<AnsNotification>::GetInstance() to
   AnsNotification::GetInstance()
3. Fix singleton.h include hygiene:
   - Add #include singleton.h to 34 files that use Singleton<>,
     DelayedSingleton<>, DECLARE_SINGLETON etc. but relied on
     transitive includes
   - Add #include nocopyable.h to 7 files that use
     DISALLOW_COPY_AND_MOVE but relied on transitive includes
   - Remove #include singleton.h from 70 files that no longer use
     any singleton.h symbols after the DelayedSingleton replacement

The function-local static in ans_notification.cpp lives in
libans_innerkits.so's data segment. AnsNotification::GetInstance() is
a non-inline member function compiled only in libans_innerkits.so and
exported via *Ans* pattern in libans_innerkits.map. All SOs call this
exported function through dynamic linking, sharing the single instance.

Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: I1089cfa5bb010daf37c68333a1e71c55fc1f16f3
2026-08-07 18:43:39 +08:00
stepend98 3f25dcccf5 Merge branch 'fix/null-check-stability' of git@gitcode.com:stepend98/notification_distributed_notification_service.git into 'master'
# Conflicts:
#   conflict services/ans/src/advanced_notification_service_ability.cpp
#   conflict services/ans/test/unittest/notification_preferences_test.cpp
2026-08-06 10:13:16 +08:00
stepend98 c5690cf239 fix: add null pointer checks to prevent crashes in notification service
Add comprehensive null pointer validation across frameworks and services
layers (notification_request, subscriber_image_util, napi converters,
geofence service, live view service, preferences, subscriber manager, etc.)
to prevent null-dereference crashes, and add unit tests covering the new
null-check branches.

Co-Authored-By: Agent
Signed-off-by: stepend98 <yangjun273@huawei.com>
Change-Id: I62f9e3a450dbdbbcf7b0657c7187c6f7709b01df
2026-08-01 16:41:22 +08:00
stepend98 8016219d9d fix(ans): fix memory leaks in NAPI async work and resource lifecycle management
Check return values of napi_create_async_work and napi_queue_async_work_with_qos, properly clean up callback references, async work objects and asynccallbackinfo on failure paths. Use unique_ptr for exception safety in FromJson, fix null deref in ANI CheckCompleteEnvironment, dlclose handle in ExtensionWrapper destructor, and destroy timers in ExtensionServiceConnection destructor.

Co-Authored-By: Agent
Signed-off-by: stepend98 <yangjun273@huawei.com>
Change-Id: I9f681bba5677db209f6f3691d19f78623699dbb3
2026-08-01 11:04:13 +08:00
stepend98 250f82ba55 fix(memleak): cleanup resources on napi async work failure and in service destructors
Co-Authored-By: Agent
Signed-off-by: stepend98 <yangjun273@huawei.com>
Change-Id: I844bc20ffa457a05d7c4753e2c0e898e8c1097c9
2026-08-01 10:42:39 +08:00
CheerfulRicky f2987c78ea fix(ans): fix warning check defects from issue #4250
Fix various static analysis findings including memory leaks, null
pointer dereferences, use-after-free risks, integer overflow, enum
range validation, and resource management issues.

A. NAPI async work return value unchecked (30+ sites): check
   napi_create_async_work/napi_queue_async_work_with_qos return values,
   free asynccallbackinfo on failure; fix subscribe.cpp UB, badge query
   timeout leak, ETS variant GetEnv leaks
C. Type safety: add enum range validation for IPC deserialization
   (SWITCH_STATE, LiveViewStatus), JSON (clone switch info), JS input
   (InputEditType, RingtoneType, BadgeStyle, SlotType); fix uint8_t
   truncation in multiline content marshalling
D. Integer overflow: replace atoi/atoll with strtol/strtoll+ERANGE;
   fix FindLastString logic error (pos != npos always true); fix
   VectorToString int64_t->int truncation; fix GetRemainPartitionSize
   returning -1 as uint64_t
E. UAF/memory: unregister distributed callbacks in destructor; add
   ffrt::wait in StopCacheCleanupTimer; unsubscribe CommonEvent in
   DialogManager destructor; remove DeathRecipient in SubscriberImpl
   destructor; wait for FFRT queue in LocalLiveViewSubscriberManager
F. new(nothrow) unchecked: add null checks for recipient_/deathRecipient_
   allocation in 5 manager classes
G. Other: implement ClearButtonIconsResource; init HaMetaMessage
   sceneId_/branchId_; add dlsym for 5 missing function pointers;
   check OH_DecodingOptions_Create return; fix GetAllDoNotDisturbProfiles
   substring match; add array length limits; check CreateTimer return;
   fix pushRecipient_ overwrite logic; add try-catch for JSON parse

Change-Id: I4204fe52d9fbbd8d89cf188892ab243847649f59

Change-Id: I5588bd9c663d54a17c429143721c124259401e8d

Change-Id: If0705f229837ed1edf0a05712481fb9cfc1f7cda

Change-Id: Id494add5740c95d908016934e69ae704c4ad6f70

Change-Id: I73990ec7e4ff7374a71e3da4692e5bc53bfdbc2c

Change-Id: I57840e82aa808259fc43b9ae8b942f9b999f1271

Change-Id: I715fc92bede97bde739aed63e384359fd39ad3d7

Change-Id: Ib7dce869072b3b4b812fa46319dca3ce946b7c5a

Change-Id: If7359da9013fb008cee436d4db3fd6aa3508421f

Change-Id: I984f57d01cc39b9682f8ce08c88b146e50d132d1

Change-Id: I5b307d34ae22ae8a3919eacb1f3d4efe6c7ef75b

Change-Id: I922a6fdfadb7344c4649a5e54f8ee439f87069cd

Change-Id: I90d91e060c92d6fb0ff056801a58dc056d51b4bc

Change-Id: I21e6e587511d98b2fff3306089b42d997333dfcf

Change-Id: Ie9afd57cfeb66e5a68fa76a35862e84b47177fbf

Change-Id: I29bc907d5653ee322b8a46c9c4523388f8492d47

Change-Id: Ie82eb2cf6541ef43bcd9254cf342e980e4ab19b7

Change-Id: I480ebfe965c7dcb13a2ca30a3b7fb73e35606309

Change-Id: I4e00bfd6020f9f6e50fcab4c7b2d11e824371417

Change-Id: I384d6621b6915c45ad4dc6013c52406bba1b2491

Change-Id: Ifb01195d74f70604e5dd1bad9e291e5ce4d96fcc

Change-Id: I99764684c4c029a114734de1161d0591d59e15c1

Change-Id: I2637febf7282779082f5135671328dfaa75f441a

Change-Id: I8db817f8e84da51e6c1bf69dfc67c90b1b516f41

Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: Idaeb6de6233925455d7da38dc41299229244ba32
2026-07-30 20:12:34 +08:00
bettykico cdb8c412d5 fix subscribeNotification bug
Co-Authored-By: Agent

Signed-off-by: bettykico <fangxiaofen1@h-partners.com>
2026-07-29 19:23:35 +08:00
bettykico 0aa7411df7 Revert "Co-Authored-By: Agent"
This reverts commit 2a0b858722.

Signed-off-by: bettykico <fangxiaofen1@h-partners.com>
2026-07-27 13:59:21 +08:00
openharmony_ci 9bff7c0b7f !4911 merge master into master
fix subscribeNotification bug & add ut

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

Issue: #4259

### 二、建议测试周期和提测地址  
  建议测试完成时间: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_distributed_notification_service!4911
2026-07-25 18:21:28 +08:00
bettykico d06233a98e fix subscribeNotifictaion bug & add ut
Co-Authored-By: Agent

Signed-off-by: bettykico <fangxiaofen1@h-partners.com>
2026-07-25 16:50:04 +08:00
openharmony_ci b3349f7cf2 !4909 merge fix/add-extension-exported-symbol into master
add extension exported symbol

Created-by: cheerful_ricky
Commit-by: CheerfulRicky
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_distributed_notification_service!4909
2026-07-24 20:27:50 +08:00
CheerfulRicky 17391e3a3b fix(napi/ani): fix hidden symbol exports in version scripts
Critical fix: libnotification_subscriber_extension_ani.map exported
ANI_Constructor (non-existent) instead of
OHOS_STS_NotificationSubscriberExtension_Creation which is the dlsym
symbol expected by NotificationSubscriberExtensionModuleLoader. Added
the missing extern "C" factory function in sts_notification_subscriber_extension.cpp.

Other fixes:
- Remove dead napi_module exports from NAPI module maps (the actual
  variable is _module; registration works via __attribute__((constructor)))
- Add vtable/typeinfo/VTT export patterns to module .so maps for CFI
  cross-dso virtual call safety on IPC callback classes
- Clean up redundant patterns in common library maps (*Common*,
  *NotificationManagerSts*, *NotificationSubScribeSts*, *ReminderAgentNapi*)
- Remove orphaned libnotification_subscriber_extension.map (not referenced
  in BUILD.gn)

Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: I6ba01c5568862e5827d56efe5cbacfd593069c50
2026-07-23 20:49:08 +08:00
CheerfulRicky 12acfae1ff add extension exported symbol
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: I73b2cf68cf02c2c8db5e683ba9a9e79112b0b87f
2026-07-23 19:58:36 +08:00
openharmony_ci e9995cb562 !4898 merge getActiveNotification_2 into master
add getActiveNotification

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

add getActiveNotification
Issue: #4245

### 二、建议测试周期和提测地址  
  建议测试完成时间: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  | 否          | 需要       | 不需要           |
|      |            |          |               |

  接口测试:

  性能测试:

  并发测试:

  其他:

Co-Authored-By: Agent

See merge request: openharmony/notification_distributed_notification_service!4898
2026-07-22 17:25:26 +08:00
bettykico 7f8f0ba4d2 add getActiveNotification
Co-Authored-By: Agent>

Signed-off-by: bettykico <fangxiaofen1@h-partners.com>
2026-07-22 16:15:50 +08:00
openharmony_ci 213aa6cfab !4896 merge master into master
add subscribeNotification

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

add subscribeNotification for priorityStrategy
Issue: #4243

### 二、建议测试周期和提测地址  
  建议测试完成时间: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  | 否          | 需要       | 不需要           |
|      |            |          |               |

  接口测试:

  性能测试:

  并发测试:

  其他:

Co-Authored-By: Agent

See merge request: openharmony/notification_distributed_notification_service!4896
2026-07-22 15:14:38 +08:00
bettykico 03ade40c37 add subscribeNotification
Signed-off-by: bettykico <fangxiaofen1@h-partners.com>
2026-07-22 11:30:31 +08:00
openharmony_ci 2879d0fc59 !4889 merge feat/code-scan-issues-fix into master
fix: resolve code scan issues including memory leaks, null derefs and JSON parse validation

Created-by: stepend98
Commit-by: stepend98
Merged-by: openharmony_ci
Description: ## 变更说明

本次提交修复通知服务代码扫描发现的多类问题:

### 1. NAPI 层内存泄漏修复
在多个 NAPI 接口的参数解析失败错误路径上,补充 `napi_delete_reference` 调用,释放已创建的 callback 引用,避免内存泄漏。

涉及文件:cancel.cpp、common_utils.cpp、distributed.cpp、disturb_mode.cpp、enable_notification.cpp、get_active.cpp、local_live_view_subscribe.cpp、napi_display_badge.cpp、napi_distributed.cpp、napi_get_active.cpp、slot.cpp

### 2. 空指针/资源泄漏修复
- `distributed_bundle_option.cpp`:FromJson 失败路径释放已分配对象
- `napi_notification_extension.cpp`:GetStageModeContext 返回值判空

### 3. Parcel 序列化边界校验
- `notification_basic_content.cpp`、`notification_multiline_content.cpp`:增加 vector size 上限校验(MAX_PARCELABLE_VECTOR_NUM)

### 4. JSON 解析容错
- 新增 `is_discarded()` 检查:notification_clone_manager.cpp、health_white_list_util.cpp
- 新增 `is_array()` 检查:notification_conversational_content.cpp

### 5. 成员初始化修复
- `badge_number_callback_data.cpp`:初始化 instanceKey_
- `sts_subscribe.cpp`:初始化 etsVm_
- `distributed_device_data.h`:初始化 deviceType_

### 6. 其他修复
- `notification_analytics_util.cpp`:timer id 类型 int32_t -> uint64_t
- `notification_preferences_info.cpp`:返回空字符串而非 nullptr
- `notification_preferences.cpp`:修复日志格式占位符

Co-Authored-By: Agent

Fixes #4237

See merge request: openharmony/notification_distributed_notification_service!4889
2026-07-21 09:31:20 +08:00
openharmony_ci 713528aaf8 !4890 merge fix/clone-bundle-collaboration-switch into master
fix(preferences): 删除分身应用时仅清理对应bundleUid的协同开关数据

Created-by: wangsen1994
Commit-by: wangsen1994
Merged-by: openharmony_ci
Description: ## 关联Issue

Closes #4238

## 问题描述

分身应用(同 bundleName、不同 uid)卸载时,会错误删除同包名下所有应用(主应用及其他分身)的应用级协同开关数据。

## 根因

`RemoveEnabledDbByBundleName` 删除键前缀遗漏 `bundleUid`,前缀匹配波及同 bundleName 的全部条目:

- 写入键:`enabledDistributedNotification-{bundleName}-{bundleUid}-{deviceType}`
- 删除前缀(修复前):`enabledDistributedNotification-{bundleName}-`

## 修复方案

在删除键前缀补上 `bundleUid`,仅命中被卸载分身自身条目;LiveView 通路同步修复。

## 变更文件

- `services/ans/src/notification_preferences_database.cpp`:`RemoveEnabledDbByBundleName` 删除键前缀补 `bundleUid`
- `services/ans/test/unittest/notification_preferences_database_test.cpp`:新增 `RemoveEnabledDbByBundleName_0200` 用例

## 验证

- 新增单测覆盖主/分身同包名不同 uid 场景,删除分身后主应用协同开关数据仍保留。
- `./build.sh --product-name rk3568 --build-target distributed_notification_service_unit_test` 构建通过。

See merge request: openharmony/notification_distributed_notification_service!4890
2026-07-17 14:16:22 +08:00
wangsen1994 210ba589c0 fix(preferences): 删除分身应用时仅清理对应bundleUid的协同开关数据
RemoveEnabledDbByBundleName 删除键前缀遗漏了 bundleUid,前缀匹配会
误删同包名下所有分身/主应用的应用级协同开关。补上 bundleUid 使删除
范围精确到被卸载分身自身。

同时从克隆备份/恢复流程中移除 CollaborationSwitch 的 ToJson/FromJson
序列化、UpdateCloneBundleInfoForDistributedEnable 及
GetDistributedEnabledForClone 调用,协同开关数据已由 disturbe DB 按
bundleName+uid 维度独立持久化,无需经克隆链路冗余存取。

并移除 NAPI 层 getDistributedBundleListByType 与 getDistributedBundleInfo
接口注册。

Signed-off-by: wangsen <wangsen51@huawei.com>
Co-Authored-By: Agent
Change-Id: Ibf5699b2dd8553ce12927b3594fc175351f2fd54
2026-07-17 10:03:44 +08:00
stepend98 e24595da91 fix: resolve code scan issues including memory leaks, null derefs and JSON parse validation
- Fix NAPI memory leaks by deleting callback references on error paths
- Add null pointer checks for context and bundle option objects
- Add bounds validation for Parcel vector sizes against MAX_PARCELABLE_VECTOR_NUM
- Add is_discarded() checks before JSON parse result usage
- Fix uninitialized member variables in constructors
- Fix timer id type from int32_t to uint64_t
- Fix log format placeholder and return empty string instead of nullptr

Co-Authored-By: Agent
Signed-off-by: stepend98 <yangjun273@huawei.com>
Change-Id: I980acf6c5aaed0e4ee31de14f246d95fae2d2c65
2026-07-16 18:52:28 +08:00
CheerfulRicky 8af6236b68 feat(rom-size): ROM size optimization phase 1 - build config and symbol visibility
Phase 1 of ROM size optimization (target: 30% reduction, baseline 7963KB).
All changes are limited to BUILD.gn/.gni/.map files, no .cpp/.h modifications.

Key changes:
- Add notification_size_opt_cflags/ldflags public variables in notification.gni
- Add -fno-rtti/-flto/-Bsymbolic/-fno-exceptions config to all production targets
- Extract ANI sts_*.cpp (21 files) to ohos_shared_library notification_ani_common
- Extract NAPI common*.cpp (12 files) to ohos_shared_library notification_napi_common
- Tighten libans_innerkits.map from global:* to class-name-based export
- Add version_script to 6 NAPI .so (export only napi_module)
- Add version_script to 4 ANI .so (export only ANI_Constructor)
- Feature-gate priority_notification/clone/geofence source files
- Add distributed_notification_service_feature_clone flag

Expected benefit: 500-1100KB reduction.

Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: I029559a06708665662b1d2f9b7f66dcae53ee96f
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
2026-07-14 10:48:53 +08:00
hanwenhui 9e2f2b585f Signed-off-by: hanwenhui <hanwenhui2@h-partners.com>
Co-Authored-By:hanwenhui
2026-07-13 15:07:08 +08:00
lx180327070811 a399c19daa native解析内存,传入路径非法时,systemui要求生成nullptr的图片
Signed-off-by: lx180327070811 <guxiang11@huawei.com>
2026-07-09 20:52:51 +08:00
openharmony_ci 809e2c1a94 !4867 merge master into master
refactor: clean up redundant logs in notification switch flow

Created-by: stepend98
Commit-by: stepend98
Merged-by: openharmony_ci
Description: ## 变更说明

精简 `GetNotificationSwitch` 通知开关查询流程中的冗余日志,减少高频路径上的日志噪声,保留关键状态日志。

## 变更范围

- `frameworks/core/src/subscriber_image_util.cpp`:移除空指针分支中的冗余 ERROR 日志
- `frameworks/js/napi/src/manager/napi_notification_switch.cpp`:移除 NAPI 异步回调中的结果 INFO 日志
- `services/ans/src/aggregation_notification/advanced_notification_aggregation_service.cpp`:缩短 success 路径 INFO 日志文本
- `services/ans/src/notification_preferences.cpp`:移除偏好设置层冗余 INFO 日志
- `services/ans/src/notification_preferences_database.cpp`:移除 DB 层冗余 INFO 日志

## 验证

- 构建目标:distributed_notification_service

Fixes #4213

See merge request: openharmony/notification_distributed_notification_service!4867
2026-07-09 10:29:51 +08:00
hanwenhui c53c736295 Co-Authored-By:hanwenhui
Signed-off-by: hanwenhui <hanwenhui2@h-partners.com>
2026-07-08 10:09:21 +08:00
stepend98 5b8355b142 refactor: clean up redundant logs in notification switch flow
Co-Authored-By: yangjun
Signed-off-by: stepend98 <yangjun273@huawei.com>
2026-07-07 17:29:38 +08:00
CheerfulRicky 52b8127606 feat(ans): limit bundles array to 1000 for isNotificationSlotEnabledByBundles
Add parameter validation in binding layer (ets/napi/ani) to reject
arrays exceeding 1000 elements, returning 401 (ERROR_PARAM_INVALID)
synchronously before async work. This aligns with the updated API
spec for batch slot enabled query.

Change-Id: I67bf86701080f3e02a39611799bf023570f8328c

Change-Id: I508bb6489191a5194f0e08b6888e69aea2ab86f6

Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: I46446109cb4bfff7c4aafa5a191b6118dbad2e36
2026-07-06 19:15:24 +08:00
openharmony_ci 68c46317b7 !4838 merge master into master
fix(remove): extend hashcode length limit and handle empty hashcode case

Created-by: stepend98
Commit-by: stepend98
Merged-by: openharmony_ci
Description: ## 变更说明

修复通知移除 API 中 hashcode 处理的两个问题:

### 问题背景
1. **hashcode 长度截断**:`frameworks/ets/ani/src/subscribe/ani_remove.cpp` 中移除通知(单个/多个 hashcode)时,使用 `STR_MAX_SIZE` 限制 hashcode 字符串长度,导致超长 hashcode 被截断,无法正确匹配移除目标通知。
2. **空 hashcode 未处理**:`frameworks/js/napi/src/remove.cpp` 中解析 hashcode 类型参数时,仅在字符串路径满足条件时赋值 `params.hashcode`,未覆盖的分支导致 hashcode 可能未被初始化,存在未定义行为风险。

### 修改内容
- `frameworks/ets/ani/src/subscribe/ani_remove.cpp`:将 `AniRemoveForHashCode` 与 `AniRemoveForHashCodes` 中的 `GetResizeStr` 长度上限由 `STR_MAX_SIZE` 调整为 `LONG_STR_MAX_SIZE`,以支持更长的 hashcode。
- `frameworks/js/napi/src/remove.cpp`:在字符串解析条件未命中时,显式将 `params.hashcode` 置为空字符串,保证参数始终被初始化。

### 影响范围
- 通知移除(remove)API 的 ArkTS NAPI 与 ANI 绑定层。
- 不涉及服务端业务逻辑与公共 API 签名变更。

Fixes #4193

See merge request: openharmony/notification_distributed_notification_service!4838
2026-07-02 12:01:12 +08:00
CheerfulRicky e86fe99db6 fix(notification): fix legacy issues in isNotificationSlotEnabledByBundles batch API
1. Empty DB query result now returns an empty Map instead of null in the
   NAPI callback; DB query failure still reports an error. The service/DB
   layers already distinguished empty (ERR_OK) from failure; this fixes
   the NAPI layer that overwrote the empty Map with null, which violated
   the declared Promise<Map<BundleOption, boolean>> return type.
2. BundleOption.uid is optional; when not filled (uid<=0), the batch path
   now resolves the uid via GenerateValidBundleOption (same as the single
   path) before querying the DB, so the correct slot key and userId are
   used. Unresolvable bundles are skipped and ERR_OK with partial results
   is returned.

Add unit tests for uid-not-filled skip and partial-result scenarios.

Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: I305f17443ebfa38eb6ead89ecbe9e42622e0da08
2026-07-01 20:06:54 +08:00
stepend98 dcd9e97571 fix(remove): extend hashcode length limit and handle empty hashcode case
Co-Authored-By: Agent
Signed-off-by: stepend98 <yangjun273@huawei.com>
2026-06-30 22:39:08 +08:00
hanwenhui c7c58db222 Co-Authored-By:hanwenhui
Signed-off-by: hanwenhui <hanwenhui2@h-partners.com>
2026-06-29 08:53:03 +08:00
openharmony_ci 1e7806b0ef !4813 merge feat/batch-slot-query-optimization into master
feat(notification): add batch slot query API and optimize getAllNotificationEnabledBundles

Created-by: cheerful_ricky
Commit-by: CheerfulRicky
Merged-by: openharmony_ci
Description: ### 关联的issue:
#4166

### 变更说明:

#### 1. 新增批量 slot 查询 API `isNotificationSlotEnabledByBundles`

将 300 次 IPC 调用缩减为 1 次,预期总耗时从 ~900ms 降低到 ~30ms。

- 新增 Parcelable 类型 `NotificationBundleSlotKey`(含 BundleOption + SlotType)
- IDL: `GetEnabledForBundleSlots` 使用 `OrderedMap<sptr<NotificationBundleSlotKey>, boolean>` 输出
- ArkTS API: `isNotificationSlotEnabledByBundles(Array<BundleSlotParameter>): Promise<Map<BundleSlotParameter, boolean>>`
- 直查 DB 精确 key(`ans_bundle_{name}{uid}_slot_type_{type}_enabled`),不经过 LRU Cache
- slot 不存在的 bundle 排除出结果集
- 批量 IN 查询每批 ≤100 个 key
- NAPI + ANI 双绑定
- 遵循错误码分层架构(`ERR_ANS_INNER_*` → `InnerErrorCode` → `InnerErrorToNative` → 外部错误码)

#### 2. 优化 `getAllNotificationEnabledBundles`

- 单次 OR 复合 QuerySql 替代全量前缀扫描(I/O 降低 80%)
- `HandleDataBaseMapInner` 正则→字符串匹配(CPU 提升 10~100x)

#### 3. 测试覆盖

- 29 个单元测试用例 + 3 个性能测试用例
- 编译验证通过(`distributed_notification_service` + `distributed_notification_service_unit_test`)

### 变更范围:

- 38 个文件修改(+2847/-9 行)
- 涵盖全链路:RDB → DB → IDL → 客户端 → 服务端 → ArkTS → NAPI/ANI → 测试

### 自检清单:

- [x] 编译通过
- [x] 无新增编译警告
- [x] 错误码遵循分层架构
- [x] 权限校验与现有接口一致(NOTIFICATION_CONTROLLER)
- [x] NAPI + ANI 双绑定同步实现
- [x] 不修改公共 API 签名、错误码、权限行为

See merge request: openharmony/notification_distributed_notification_service!4813
2026-06-26 10:00:50 +08:00
openharmony_ci bc2e4f6acb !4808 merge Step-WarningFix into master
fix: suppress warnings via null checks, bounds validation, and scope fixes

Created-by: stepend98
Commit-by: stepend98
Merged-by: openharmony_ci
Description: ## 变更说明

修复通知子系统中多处编译器告警:

1. **空指针保护**:在 `NotificationLocalLiveViewButton::Marshalling`、`JsNotificationSubscriberExtension::Init`、`napi_open_settings` 上下文获取、扩展订阅信息处理等处增加空指针检查,防止空指针解引用导致崩溃。

2. **冗余代码移除**:移除 `advanced_notification_utils.cpp` 中对系统应用身份的冗余校验,该函数仅由系统服务内部调用,无需重复鉴权。

3. **变量作用域修复**:在 `notification_analytics_util.cpp` 的 `BuildAnsData` 中将 `controlFlags` 声明移至 `if` 块外,修复变量作用域告警。

Fixes #4162

See merge request: openharmony/notification_distributed_notification_service!4808
2026-06-25 21:55:36 +08:00
openharmony_ci 64b8ce7d10 !4810 merge master into master
check calendar want agent

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

![image.png](https://raw.gitcode.com/user-images/assets/4402302/4eabe882-3f44-4bcf-9615-cc241149d543/image.png 'image.png')

### 二、建议测试周期和提测地址  
  建议测试完成时间: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_distributed_notification_service!4810
2026-06-25 20:18:43 +08:00
openharmony_ci 3bf094e06f !4817 merge feat/error-code-layering into master
update ans_service_errors_test expected values

Created-by: cheerful_ricky
Commit-by: CheerfulRicky
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_distributed_notification_service!4817
2026-06-25 16:19:03 +08:00
CheerfulRicky 0c38587493 feat(notification): add batch slot query API and optimize getAllNotificationEnabledBundles
Add isNotificationSlotEnabledByBundles batch slot query API to query
multiple bundles' slot enabled state in a single IPC call, avoiding the
performance degradation caused by LRU cache misses in the single-query
path. Optimize getAllNotificationEnabledBundles to only query
_enabledNotification keys (filtered by VALUE IN ('1','3')) and parse
bundleName/uid from the key, reducing I/O by ~66%.

- Add IDL method GetEnabledForBundleSlots with OrderedMap output
- Add full-stack implementation: server, DB, client, helper, NAPI, ANI
- Unify single query path to bypass LRU cache via batch query internally
- Add QueryDataInKeys batched IN query and QueryEnabledBundles in RDB layer
- Add unit tests for server, DB layer, and RDB batch query
- Add performance test (300-bundle batch query < 30ms target)

Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Co-Authored-By: Agent
Change-Id: I59ed3041c14b33a2fbe69517d6b366597f03b11b
2026-06-24 18:10:37 +08:00
CheerfulRicky e7f1046bb1 fix(napi): restore SetEnableClassification and SetNeedSilentReplayOnSubscribe before SubscribeNotificationV26
Error code layering refactor moved SubscribeNotificationV26 call before
SetEnableClassification and SetNeedSilentReplayOnSubscribe, causing these
fields to be unset during subscription. Restore the original order: set
all subscribeInfo fields first, then call SubscribeNotificationV26.

Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Co-Authored-By: Agent
Change-Id: Ia7c97753fa320567ea1ea67acf5e08efea66f145
2026-06-24 17:33:18 +08:00
openharmony_ci 662203fb72 !4815 merge Step-LiveviewCancelFailed into master
fix: use dynamic buffer with truncation for hashcode string parsing in NAPI

Created-by: stepend98
Commit-by: stepend98
Merged-by: openharmony_ci
Description: ## 问题描述

在 NAPI 层的 hashcode 字符串解析中,使用固定大小的 `STR_MAX_SIZE`(204) 缓冲区读取字符串,当 hashcode 字符串长度超过缓冲区大小时会导致截断,引发功能异常。

## 修复方案

将 `frameworks/js/napi/src/common.cpp` 和 `frameworks/js/napi/src/remove.cpp` 中的固定缓冲区替换为动态分配方式,并增加最大长度限制:
1. 先调用 `napi_get_value_string_utf8` 获取实际字符串长度
2. 若长度超过 `LONG_STR_MAX_SIZE`(1028),截断至该限制并记录 warning 日志
3. 根据实际长度动态分配 `std::string` 缓冲区
4. 再次调用 `napi_get_value_string_utf8` 读取字符串

## 影响范围

- `frameworks/js/napi/src/common.cpp`: `GetHashCodes` 函数(批量 hashcode 解析)
- `frameworks/js/napi/src/remove.cpp`: `ParseHashcodeTypeParams` 函数(单个 hashcode 解析)

## 接口行为

超长字符串做截断处理,不变更接口行为,仅记录 warning 日志。

Fixes #4167


See merge request: openharmony/notification_distributed_notification_service!4815
2026-06-23 20:11:30 +08:00
openharmony_ci 380acd4d15 !4809 merge Step-NapiExceptionHandle into master
fix: use NapiRejectError for proper Promise rejection in notification switch NAPI

Created-by: stepend98
Commit-by: stepend98
Merged-by: openharmony_ci
Description: ## 变更说明

修复通知开关 NAPI 接口中不规范的异常处理方式,统一使用 `NapiRejectError` 进行 Promise 拒绝。

Related Issue: #4163

### 变更内容

- `HandleAsyncWorkFailure`: `NapiGetUndefined` → `NapiRejectError(ERR_ANS_INNER_TASK_ERR)`
- `NapiSetNotificationSwitch` 参数解析失败: `NapiGetUndefined` → `NapiRejectError(ERR_ANS_INNER_INVALID_PARAM)`
- `NapiSetNotificationSwitch` 内存分配失败: `NapiThrow` + `JSParaError` → `NapiRejectError(ERR_ANS_INNER_NO_MEMORY)`
- `NapiGetNotificationSwitch` 参数解析失败: `NapiGetUndefined` → `NapiRejectError(ERR_ANS_INNER_INVALID_PARAM)`
- `NapiGetNotificationSwitch` 内存分配失败: `NapiThrow` + `JSParaError` → `NapiRejectError(ERR_ANS_INNER_NO_MEMORY)`

### 修改文件

- `frameworks/js/napi/src/manager/napi_notification_switch.cpp`

See merge request: openharmony/notification_distributed_notification_service!4809
2026-06-23 18:04:22 +08:00
stepend98 30ba5b8c67 fix: suppress warnings via null checks, bounds validation, and scope fixes
Co-Authored-By: yangjun
Signed-off-by: stepend98 <yangjun273@huawei.com>
2026-06-23 16:37:58 +08:00
openharmony_ci 2e5422468c !4812 merge feat/error-code-layering into master
fix(napi): ReturnCallbackPromise use CreateErrorValueLegacy to preserve nativeCode

Created-by: cheerful_ricky
Commit-by: CheerfulRicky
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_distributed_notification_service!4812
2026-06-23 11:51:43 +08:00