Group the boolean behavior flags previously scattered across function signatures into the...
Created-by: let_it_rot
Commit-by: let_it_rot
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)
Group the boolean behavior flags previously scattered across function signatures into the ShowLimit struct, and use a new isUpdateDeliveryTime flag to control whether the notification delivery time is refreshed when showing a reminder.
- Add isPlaySound/isSysTimeChanged/isCloseDefaultSound/isSlienceNotification fields to ShowLimit in reminder_data_manager.h
- Add isUpdateDeliveryTime field (default true) to ShowLimit
- ShowReminder: signature changes to (reminder, const ShowLimit& limits); pass limits.isUpdateDeliveryTime through to ReminderRequest::UpdateNotificationRequest
- HandleImmediatelyShow: signature changes to (vector, ShowLimit&, size_t index = 0); OnShow and the recursive ffrt callback now read isSysTimeChanged/isSlienceNotification from limits
- Update all call sites (OnLanguageChanged, LoadShareReminders, UpdateShareReminders, OnDataShareInsertOrDelete, InitShareReminders, boot complete, system time change, ShowActiveReminder) to populate the relevant flags on a local ShowLimit before invoking
- isUpdateDeliveryTime is true only for normal timer trigger (ShowActiveReminder) and system time change trigger; false for all other cases (boot, init, data share, language change)
- Update unit test and both fuzz harnesses to the new signatures

### 二、建议测试周期和提测地址
建议测试完成时间: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!4975
Add ans_service_sources_test (ohos_static_library, testonly) that wraps ans_service_sources and automatically provides the mock_ans_rdb_mgr_builder strong override (isolated temp DB). All test targets now depend on ans_service_sources_test instead of ans_service_sources, so new test suites automatically get RDB isolation without manual changes.
ans_service_sources_test_config propagates all needed include paths (ans headers, rdb headers, mock headers) to test targets. The mock source (mock_ans_rdb_mgr_builder.cpp) is compiled once into the static lib, avoiding include-path propagation issues with source_set recompilation.
Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: Ieafd58f9f1e1433e3381c89a8c105f7191662986
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
signatures into the ShowLimit struct, and use a new isUpdateDeliveryTime
flag to control whether the notification delivery time is refreshed when
showing a reminder.
- Add isPlaySound/isSysTimeChanged/isCloseDefaultSound/isSlienceNotification
fields to ShowLimit in reminder_data_manager.h
- Add isUpdateDeliveryTime field (default true) to ShowLimit
- ShowReminder: signature changes to (reminder, const ShowLimit& limits);
pass limits.isUpdateDeliveryTime through to ReminderRequest::
UpdateNotificationRequest
- HandleImmediatelyShow: signature changes to (vector, ShowLimit&,
size_t index = 0); OnShow and the recursive ffrt callback now read
isSysTimeChanged/isSlienceNotification from limits
- Update all call sites (OnLanguageChanged, LoadShareReminders,
UpdateShareReminders, OnDataShareInsertOrDelete, InitShareReminders,
boot complete, system time change, ShowActiveReminder) to populate the
relevant flags on a local ShowLimit before invoking
- isUpdateDeliveryTime is true only for normal timer trigger
(ShowActiveReminder) and system time change trigger; false for all
other cases (boot, init, data share, language change)
- Update unit test and both fuzz harnesses to the new signatures
Signed-off-by: let_it_rot <gaojiaqi7@h-partners.com>
Co-Authored-By: Agent
Refactoring calendar reminder with repeated triggering of time calculation for month and day, and fixing multiple defects
Created-by: let_it_rot
Commit-by: let_it_rot
Merged-by: openharmony_ci
Description: ### 一、内容说明(相关的Issue)
Refactoring calendar reminder with repeated triggering of time calculation for month and day, and fixing multiple defects
Abandoning the old GetNextDay+monthly jump algorithm and replacing it with a single-layer monthly jump scheme based on absolute month numbers,
Year=absMonth/12 automatically crosses years, eliminating the hidden danger of manual setYear accumulation. Fix the following defects:
1. Multiple accumulations of setYear after the New Year result in a delay of 1 to N years in the next cycle
2. The candidate trigger time is earlier than the start date of firstDesignate
3. When firstDesignate exceeds the coverage range of the loop, it is misjudged as expired
4. setDay=255 is incorrectly normalized by mktime (such as invalid configuration for Hb 30)
Scan range expanded to 5 years, correctly handling the leap year cycle on February 29th.
Add 10 regression tests covering all reachable branches, constructed based on relative time to ensure future feasibility.

### 二、建议测试周期和提测地址
建议测试完成时间: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!4967
Abandoning the old GetNextDay+monthly jump algorithm and replacing it with a single-layer monthly jump scheme based on absolute month numbers,
Year=absMonth/12 automatically crosses years, eliminating the hidden danger of manual setYear accumulation. Fix the following defects:
1. Multiple accumulations of setYear after the New Year result in a delay of 1 to N years in the next cycle
2. The candidate trigger time is earlier than the start date of firstDesignate
3. When firstDesignate exceeds the coverage range of the loop, it is misjudged as expired
4. setDay=255 is incorrectly normalized by mktime (such as invalid configuration for Hb 30)
Scan range expanded to 5 years, correctly handling the leap year cycle on February 29th.
Add 10 regression tests covering all reachable branches, constructed based on relative time to ensure future feasibility.
Signed-off-by: let_it_rot <gaojiaqi7@h-partners.com>
Co-Authored-By: Agent
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
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
1. NotificationPreferences::GetInstance() and SystemSoundHelper::GetInstance():
replace broken DCLP with Meyer's singleton (C++11 thread-safe static local).
The DCLP had unprotected shared_ptr reads causing data race when static
instance_ was destroyed during process exit while ffrt worker threads
called GetInstance().
2. ClearRingtoneByApplication / ClearOverTimeRingToneInfo:
- Remove 5-second delay (DEL_TASK_DELAY) from Submit calls. The delay
caused SelfClean()'s drain to not wait for delayed tasks, leaving them
pending after process exit.
- Remove redundant std::bind wrapper, pass lambda directly.
- Use Submit(func) without delay parameter.
3. serviceprivateutilsa_fuzzer: wrap direct DeleteAllByUserStopped() call
with notificationSvrQueue_.SyncSubmit() to serialize with async tasks
from OnUserRemoved/OnUserStopped, preventing concurrent read/write race
on notificationList_ (list iterator use-after-free).
4. Fix empty if block in mock_ans_rdb_mgr_builder.cpp (cpplint).
Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: I8197f195c73f6cf2ea90e5a68c2afdea00d73ac0
Make GetAnsNotificationRdbMgrInstance() a weak symbol and override it in a single shared test mock (frameworks/test/moduletest/mock) so the in-process service constructed by tests operates on an isolated temp DB (/data/local/tmp/ans_rdb_test_<pid>/notificationdb_test.db) instead of the real notificationdb.db. All affected test targets reference the single mock via absolute path (no duplicate files).
Root cause: tests that call ClearNotificationInRestoreFactorySettings() invoke rdbDataManager_->Destroy() which deletes the DB file. Without an RDB mock, the real notificationdb.db is deleted on device, wiping real data.
Scope: all tests calling ClearNotificationInRestoreFactorySettings without an RDB mock - ans_module_test (services/test/moduletest), 10 UT targets in services/ans/test/unittest (permission_filter, notification_service, live_view, slot, utils, snooze_delay, service_publish, preferences, ringtone, geofence), aggregation_test, badge_manager_test, plus the publish/slot moduletest.
Review fixes: DestroyTestRdb now resets the static instance and removes the temp dir (rmdir); mkdir checks errno==EEXIST. Empty NtfRdbHook is intentional (nullptr-safe per docs, avoids pulling hisysevent-dependent production hooks into tests; hooks are DFX/observational and do not affect CRUD).
Verified on device: slot MST 12/12 pass both runs; real notificationdb.db mtime unchanged; full unittest 99.5% pass (3255/3273), 18 failures in unmodified binaries (pre-existing).
Co-Authored-By: Agent
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
Change-Id: I7e076d07003d6e30813e0f0f72e7f6ad38b8186d
Signed-off-by: CheerfulRicky <yuegang7@h-partners.com>
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
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