diff --git a/bundle.json b/bundle.json
index 02459d490224809cc972a730656ffb6a9a51f8fd..620c6674f4d1e8a1579da539e16ce5ac7e07df6d 100644
--- a/bundle.json
+++ b/bundle.json
@@ -38,8 +38,7 @@
"name": "ans_standard",
"subsystem": "notification",
"syscap": [
- "SystemCapability.Notification.Notification",
- "SystemCapability.Notification.ReminderAgent"
+ "SystemCapability.DistributedNotificationService"
],
"features": [],
"adapted_system_type": [
diff --git a/frameworks/ans/core/BUILD.gn b/frameworks/ans/core/BUILD.gn
index 63e45c809adf51b57370f2788351f58a83be0184..8c11721180255b1925c3c4962f9acd5d38a62784 100644
--- a/frameworks/ans/core/BUILD.gn
+++ b/frameworks/ans/core/BUILD.gn
@@ -78,7 +78,6 @@ ohos_shared_library("ans_core") {
"${frameworks_path}/ans/native/src/reminder_request_alarm.cpp",
"${frameworks_path}/ans/native/src/reminder_request_calendar.cpp",
"${frameworks_path}/ans/native/src/reminder_request_timer.cpp",
- "${frameworks_path}/ans/native/src/reminder_store.cpp",
]
configs = [ ":private_config" ]
@@ -93,13 +92,12 @@ ohos_shared_library("ans_core") {
external_deps = [
"ability_base:want",
- "ability_base:zuri",
"ability_runtime:wantagent_innerkits",
"bundle_framework:appexecfwk_base",
+ "dmsfwk_standard:zuri",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"multimedia_image_standard:image_native",
- "native_appdatamgr:native_rdb",
"os_account_standard:os_account_innerkits",
"samgr_standard:samgr_proxy",
"time_native:time_service",
diff --git a/frameworks/ans/core/src/ans_notification.cpp b/frameworks/ans/core/src/ans_notification.cpp
index 02f3ff0d3c28e1b70585239504d67a7ffb4134ae..fb2439edb46e917393addc84ce7b0b6eed089a26 100644
--- a/frameworks/ans/core/src/ans_notification.cpp
+++ b/frameworks/ans/core/src/ans_notification.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -1238,7 +1238,11 @@ ErrCode AnsNotification::IsSupportTemplate(const std::string &templateName, bool
bool AnsNotification::IsNonDistributedNotificationType(const NotificationContent::Type &type)
{
- return ((type == NotificationContent::Type::CONVERSATION) || (type == NotificationContent::Type::PICTURE));
+ if ((type == NotificationContent::Type::CONVERSATION) ||
+ (type == NotificationContent::Type::PICTURE)) {
+ return true;
+ }
+ return false;
}
ErrCode AnsNotification::IsAllowedNotify(const int32_t &userId, bool &allowed)
diff --git a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css
index 7afe50dcd4bab9a60f6f5c77b691ed2f200d5cca..cf6a1e51c1f0ea48e7e44258d6839b83c8e4cb0d 100644
--- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css
+++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css
@@ -1,18 +1,3 @@
-/*
- * Copyright (c) 2022 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
.container {
display: flex;
flex-direction: column;
diff --git a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml
index 73e8c517ae776509ae3d4a2cb803c5b6acb6fd52..98272a4d6462f907a61022844df7985406c2099e 100644
--- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml
+++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml
@@ -1,18 +1,3 @@
-
-
diff --git a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js
index 202cc62bc070331ffd60566432dc5122f600cc6b..928dc3b8b789e0fdcf0c8a6239d2dfde8a806ec1 100644
--- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js
+++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js
@@ -1,18 +1,3 @@
-/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
import router from '@ohos.router'
export default {
diff --git a/frameworks/ans/native/BUILD.gn b/frameworks/ans/native/BUILD.gn
index 7bdd6531526aa9ac6b1842b72f7da87992383378..059c83526b4f2a84e812e25fc2deb2539450e4a3 100644
--- a/frameworks/ans/native/BUILD.gn
+++ b/frameworks/ans/native/BUILD.gn
@@ -85,12 +85,11 @@ ohos_shared_library("ans_innerkits") {
external_deps = [
"ability_base:want",
- "ability_base:zuri",
"ability_runtime:wantagent_innerkits",
+ "dmsfwk_standard:zuri",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"multimedia_image_standard:image_native",
- "native_appdatamgr:native_rdb",
"samgr_standard:samgr_proxy",
]
diff --git a/frameworks/ans/native/src/notification.cpp b/frameworks/ans/native/src/notification.cpp
index 0773681bda983ca3e0bc266db9e911016c0a71be..613c42646030dd35bc5e0fceaaac6a6e29f23e53 100644
--- a/frameworks/ans/native/src/notification.cpp
+++ b/frameworks/ans/native/src/notification.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -246,7 +246,7 @@ bool Notification::MarshallingBool(Parcel &parcel) const
bool Notification::MarshallingString(Parcel &parcel) const
{
if (!parcel.WriteString(key_)) {
- ANS_LOGE("Can't write key");
+ ANS_LOGE("Can't wirte key");
return false;
}
@@ -258,7 +258,7 @@ bool Notification::MarshallingString(Parcel &parcel) const
}
if (!parcel.WriteString(deviceId_)) {
- ANS_LOGE("Can't write deviceId");
+ ANS_LOGE("Can't wirte deviceId");
return false;
}
diff --git a/frameworks/ans/native/src/notification_subscriber.cpp b/frameworks/ans/native/src/notification_subscriber.cpp
index a0865fa929e0d5f474c1841d52efe204f2fe7852..e3a9a3c334858baa5391f370ed84d6b87a2a8676 100644
--- a/frameworks/ans/native/src/notification_subscriber.cpp
+++ b/frameworks/ans/native/src/notification_subscriber.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -99,9 +99,9 @@ void NotificationSubscriber::SubscriberImpl::OnEnabledNotificationChanged(
bool NotificationSubscriber::SubscriberImpl::GetAnsManagerProxy()
{
- if (proxy_ == nullptr) {
+ if (nullptr == proxy_) {
std::lock_guard lock(mutex_);
- if (proxy_ == nullptr) {
+ if (nullptr == proxy_) {
sptr systemAbilityManager =
SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
if (!systemAbilityManager) {
diff --git a/frameworks/ans/native/src/reminder_request.cpp b/frameworks/ans/native/src/reminder_request.cpp
index 381d0bb5db61d5808adde21dbfa8374ef2aba3a9..fec50a742880cc33a04bf0847565923dfb11bc92 100644
--- a/frameworks/ans/native/src/reminder_request.cpp
+++ b/frameworks/ans/native/src/reminder_request.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -21,7 +21,6 @@
#include "ipc_skeleton.h"
#include "iservice_registry.h"
#include "os_account_manager.h"
-#include "reminder_store.h"
#include "system_ability_definition.h"
#include "want_agent_helper.h"
@@ -51,45 +50,12 @@ const std::string ReminderRequest::REMINDER_EVENT_ALERT_TIMEOUT = "ohos.event.no
const std::string ReminderRequest::REMINDER_EVENT_REMOVE_NOTIFICATION =
"ohos.event.notification.reminder.REMOVE_NOTIFICATION";
const std::string ReminderRequest::PARAM_REMINDER_ID = "REMINDER_ID";
-const std::string ReminderRequest::SEP_BUTTON_SINGLE = "";
-const std::string ReminderRequest::SEP_BUTTON_MULTI = "";
-const std::string ReminderRequest::SEP_WANT_AGENT = "";
-
-// For database recovery.
-const std::string ReminderRequest::REMINDER_ID = "reminder_id";
-const std::string ReminderRequest::PKG_NAME = "package_name";
-const std::string ReminderRequest::USER_ID = "user_id";
-const std::string ReminderRequest::UID = "uid";
-const std::string ReminderRequest::APP_LABEL = "app_label";
-const std::string ReminderRequest::REMINDER_TYPE = "reminder_type";
-const std::string ReminderRequest::REMINDER_TIME = "reminder_time";
-const std::string ReminderRequest::TRIGGER_TIME = "trigger_time";
-const std::string ReminderRequest::RTC_TRIGGER_TIME = "rtc_trigger_time";
-const std::string ReminderRequest::TIME_INTERVAL = "time_interval";
-const std::string ReminderRequest::SNOOZE_TIMES = "snooze_times";
-const std::string ReminderRequest::DYNAMIC_SNOOZE_TIMES = "dynamic_snooze_times";
-const std::string ReminderRequest::RING_DURATION = "ring_duration";
-const std::string ReminderRequest::IS_EXPIRED = "is_expired";
-const std::string ReminderRequest::IS_ACTIVE = "is_active";
-const std::string ReminderRequest::STATE = "state";
-const std::string ReminderRequest::ZONE_ID = "zone_id";
-const std::string ReminderRequest::HAS_SCHEDULED_TIMEOUT = "has_ScheduledTimeout";
-const std::string ReminderRequest::ACTION_BUTTON_INFO = "button_info";
-const std::string ReminderRequest::SLOT_ID = "slot_id";
-const std::string ReminderRequest::NOTIFICATION_ID = "notification_id";
-const std::string ReminderRequest::TITLE = "title";
-const std::string ReminderRequest::CONTENT = "content";
-const std::string ReminderRequest::SNOOZE_CONTENT = "snooze_content";
-const std::string ReminderRequest::EXPIRED_CONTENT = "expired_content";
-const std::string ReminderRequest::AGENT = "agent";
-const std::string ReminderRequest::MAX_SCREEN_AGENT = "maxScreen_agent";
-
-std::string ReminderRequest::sqlOfAddColumns = "";
-std::vector ReminderRequest::columns;
ReminderRequest::ReminderRequest()
{
- InitServerObj();
+ wantAgentInfo_ = wantAgentInfo_ == nullptr ? std::make_shared() : wantAgentInfo_;
+ maxScreenWantAgentInfo_ =
+ maxScreenWantAgentInfo_ == nullptr ? std::make_shared() : maxScreenWantAgentInfo_;
}
ReminderRequest::ReminderRequest(const ReminderRequest &other)
@@ -117,16 +83,12 @@ ReminderRequest::ReminderRequest(const ReminderRequest &other)
this->actionButtonMap_ = other.actionButtonMap_;
}
-ReminderRequest::ReminderRequest(int32_t reminderId)
-{
- reminderId_ = reminderId;
- InitServerObj();
-}
-
ReminderRequest::ReminderRequest(ReminderType reminderType)
{
reminderType_ = reminderType;
- InitServerObj();
+ wantAgentInfo_ = wantAgentInfo_ == nullptr ? std::make_shared() : wantAgentInfo_;
+ maxScreenWantAgentInfo_ =
+ maxScreenWantAgentInfo_ == nullptr ? std::make_shared() : maxScreenWantAgentInfo_;
}
bool ReminderRequest::CanRemove() const
@@ -166,7 +128,7 @@ std::string ReminderRequest::Dump() const
ReminderRequest& ReminderRequest::SetActionButton(const std::string &title, const ActionButtonType &type)
{
- if ((type != ActionButtonType::CLOSE) && (type != ActionButtonType::SNOOZE)) {
+ if (type != ActionButtonType::CLOSE && type != ActionButtonType::SNOOZE) {
ANSR_LOGI("Button type only support: %{public}d or %{public}d",
static_cast(ActionButtonType::CLOSE), static_cast(ActionButtonType::SNOOZE));
return *this;
@@ -211,11 +173,6 @@ void ReminderRequest::InitUserId(const int &userId)
userId_ = userId;
}
-void ReminderRequest::InitUid(const int32_t &uid)
-{
- uid_ = uid;
-}
-
bool ReminderRequest::IsExpired() const
{
return isExpired_;
@@ -419,192 +376,6 @@ bool ReminderRequest::OnTimeZoneChange()
triggerTimeInMilli_, GetDurationSinceEpochInMilli(newZoneTriggerTime), nextTriggerTime);
}
-int64_t ReminderRequest::RecoverInt64FromDb(const std::shared_ptr &resultSet,
- const std::string &columnName, const DbRecoveryType &columnType)
-{
- if (resultSet == nullptr) {
- ANSR_LOGE("ResultSet is null");
- return 0;
- }
- switch (columnType) {
- case (DbRecoveryType::INT): {
- int value;
- resultSet->GetInt(ReminderStore::GetColumnIndex(columnName), value);
- return static_cast(value);
- }
- case (DbRecoveryType::LONG): {
- int64_t value;
- resultSet->GetLong(ReminderStore::GetColumnIndex(columnName), value);
- return value;
- }
- default: {
- ANSR_LOGD("ColumnType not support.");
- break;
- }
- }
- ANSR_LOGE("Recover data error");
- return 0;
-}
-
-void ReminderRequest::RecoverFromDb(const std::shared_ptr &resultSet)
-{
- if (resultSet == nullptr) {
- ANSR_LOGE("ResultSet is null");
- return;
- }
-
- // reminderId
- resultSet->GetInt(ReminderStore::GetColumnIndex(REMINDER_ID), reminderId_);
-
- // userId
- resultSet->GetInt(ReminderStore::GetColumnIndex(USER_ID), userId_);
-
- // bundleName
- resultSet->GetString(ReminderStore::GetColumnIndex(PKG_NAME), bundleName_);
-
- // uid
- resultSet->GetInt(ReminderStore::GetColumnIndex(UID), uid_);
-
- // reminderType
- int reminderType;
- resultSet->GetInt(ReminderStore::GetColumnIndex(REMINDER_TYPE), reminderType);
- reminderType_ = ReminderType(reminderType);
-
- // reminderTime
- reminderTimeInMilli_ =
- static_cast(RecoverInt64FromDb(resultSet, REMINDER_TIME, DbRecoveryType::LONG));
-
- // triggerTime
- triggerTimeInMilli_ =
- static_cast(RecoverInt64FromDb(resultSet, TRIGGER_TIME, DbRecoveryType::LONG));
-
- // timeInterval
- uint64_t timeIntervalInSecond =
- static_cast(RecoverInt64FromDb(resultSet, TIME_INTERVAL, DbRecoveryType::LONG));
- SetTimeInterval(timeIntervalInSecond);
-
- // snoozeTimes
- snoozeTimes_ = static_cast(RecoverInt64FromDb(resultSet, SNOOZE_TIMES, DbRecoveryType::INT));
-
- // dynamicSnoozeTimes
- snoozeTimesDynamic_ =
- static_cast(RecoverInt64FromDb(resultSet, DYNAMIC_SNOOZE_TIMES, DbRecoveryType::INT));
-
- // ringDuration
- uint64_t ringDurationInSecond =
- static_cast(RecoverInt64FromDb(resultSet, RING_DURATION, DbRecoveryType::LONG));
- SetRingDuration(ringDurationInSecond);
-
- // isExpired
- std::string isExpired;
- resultSet->GetString(ReminderStore::GetColumnIndex(IS_EXPIRED), isExpired);
- isExpired_ = isExpired == "true" ? true : false;
-
- // state
- state_ = static_cast(RecoverInt64FromDb(resultSet, STATE, DbRecoveryType::INT));
-
- // action buttons
- RecoverActionButton(resultSet);
-
- // slotType
- int slotType;
- resultSet->GetInt(ReminderStore::GetColumnIndex(SLOT_ID), slotType);
- slotType_ = NotificationConstant::SlotType(slotType);
-
- // notification id
- resultSet->GetInt(ReminderStore::GetColumnIndex(NOTIFICATION_ID), notificationId_);
-
- // title
- resultSet->GetString(ReminderStore::GetColumnIndex(TITLE), title_);
-
- // content
- resultSet->GetString(ReminderStore::GetColumnIndex(CONTENT), content_);
-
- // snoozeContent
- resultSet->GetString(ReminderStore::GetColumnIndex(SNOOZE_CONTENT), snoozeContent_);
-
- // expiredContent
- resultSet->GetString(ReminderStore::GetColumnIndex(EXPIRED_CONTENT), expiredContent_);
-
- InitNotificationRequest(); // must set before wantAgent & maxScreenWantAgent
-
- // wantAgent
- std::string wantAgent;
- resultSet->GetString(ReminderStore::GetColumnIndex(AGENT), wantAgent);
- RecoverWantAgent(wantAgent, 0);
-
- // maxScreenWantAgent
- std::string maxScreenWantAgent;
- resultSet->GetString(ReminderStore::GetColumnIndex(MAX_SCREEN_AGENT), maxScreenWantAgent);
- RecoverWantAgent(wantAgent, 1);
-}
-
-void ReminderRequest::RecoverActionButton(const std::shared_ptr &resultSet)
-{
- if (resultSet == nullptr) {
- ANSR_LOGE("ResultSet is null");
- return;
- }
- std::string actionButtonInfo;
- resultSet->GetString(ReminderStore::GetColumnIndex(ACTION_BUTTON_INFO), actionButtonInfo);
- std::vector multiButton = StringSplit(actionButtonInfo, SEP_BUTTON_MULTI);
- for (auto button : multiButton) {
- std::vector singleButton = StringSplit(button, SEP_BUTTON_SINGLE);
- SetActionButton(singleButton.at(1), ActionButtonType(std::stoi(singleButton.at(0), nullptr)));
- }
-}
-
-std::vector ReminderRequest::StringSplit(std::string source, const std::string &split) const
-{
- std::vector result;
- if (source.empty()) {
- return result;
- }
- size_t pos = 0;
- while ((pos = source.find(split)) != std::string::npos) {
- std::string token = source.substr(0, pos);
- if (!token.empty()) {
- result.push_back(token);
- }
- source.erase(0, pos + split.length());
- }
- if (!source.empty()) {
- result.push_back(source);
- }
- return result;
-}
-
-void ReminderRequest::RecoverWantAgent(std::string wantAgentInfo, const uint8_t &type)
-{
- std::vector info = StringSplit(wantAgentInfo, ReminderRequest::SEP_WANT_AGENT);
- uint8_t minLen = 2;
- if (info.size() < minLen) {
- ANSR_LOGW("RecoverWantAgent fail");
- return;
- }
- ANSR_LOGD("pkg=%{public}s, ability=%{public}s", info.at(0).c_str(), info.at(1).c_str());
- switch (type) {
- case 0: {
- auto wantAgentInfo = std::make_shared();
- wantAgentInfo->pkgName = info.at(0);
- wantAgentInfo->abilityName = info.at(1);
- SetWantAgentInfo(wantAgentInfo);
- break;
- }
- case 1: {
- auto maxScreenWantAgentInfo = std::make_shared();
- maxScreenWantAgentInfo->pkgName = info.at(0);
- maxScreenWantAgentInfo->abilityName = info.at(1);
- SetMaxScreenWantAgentInfo(maxScreenWantAgentInfo);
- break;
- }
- default: {
- ANSR_LOGW("RecoverWantAgent type not support");
- break;
- }
- }
-}
-
ReminderRequest& ReminderRequest::SetMaxScreenWantAgentInfo(
const std::shared_ptr &maxScreenWantAgentInfo)
{
@@ -645,7 +416,7 @@ ReminderRequest& ReminderRequest::SetSnoozeTimesDynamic(const uint8_t snooziTime
ReminderRequest& ReminderRequest::SetTimeInterval(const uint64_t timeIntervalInSeconds)
{
- if ((timeIntervalInSeconds < 0) || (timeIntervalInSeconds > (UINT64_MAX / MILLI_SECONDS))) {
+ if (timeIntervalInSeconds < 0 || timeIntervalInSeconds > (UINT64_MAX / MILLI_SECONDS)) {
ANSR_LOGW("SetTimeInterval, replace to set (0s), for the given is out of legal range");
timeIntervalInMilli_ = 0;
} else {
@@ -744,7 +515,7 @@ void ReminderRequest::SetReminderTimeInMilli(const uint64_t reminderTimeInMilli)
ReminderRequest& ReminderRequest::SetRingDuration(const uint64_t ringDurationInSeconds)
{
- if ((ringDurationInSeconds <= 0) || (ringDurationInSeconds > (UINT64_MAX / MILLI_SECONDS))) {
+ if (ringDurationInSeconds <= 0 || ringDurationInSeconds > (UINT64_MAX / MILLI_SECONDS)) {
ANSR_LOGW("setRingDuration, replace to set (1s), for the given is out of legal range");
ringDurationInMilli_ = MILLI_SECONDS;
} else {
@@ -793,16 +564,6 @@ uint64_t ReminderRequest::GetTriggerTimeInMilli() const
return triggerTimeInMilli_;
}
-int ReminderRequest::GetUserId() const
-{
- return userId_;
-}
-
-int32_t ReminderRequest::GetUid() const
-{
- return uid_;
-}
-
std::shared_ptr ReminderRequest::GetWantAgentInfo() const
{
return wantAgentInfo_;
@@ -849,11 +610,6 @@ void ReminderRequest::UpdateNotificationRequest(UpdateNotificationType type, std
SetMaxScreenWantAgent(maxScreenWantAgent);
break;
}
- case UpdateNotificationType::BUNDLE_INFO: {
- ANSR_LOGI("UpdateNotification hap information");
- UpdateNotificationBundleInfo();
- break;
- }
case UpdateNotificationType::CONTENT: {
break;
}
@@ -1033,7 +789,7 @@ bool ReminderRequest::ReadFromParcel(Parcel &parcel)
ANSR_LOGE("Failed to read tempReminderId");
return false;
}
- reminderId_ = (tempReminderId == -1) ? reminderId_ : tempReminderId;
+ reminderId_ = tempReminderId == -1 ? reminderId_ : tempReminderId;
if (!parcel.ReadInt32(notificationId_)) {
ANSR_LOGE("Failed to read notificationId");
@@ -1121,13 +877,6 @@ bool ReminderRequest::InitNotificationRequest()
return true;
}
-void ReminderRequest::InitServerObj()
-{
- wantAgentInfo_ = wantAgentInfo_ == nullptr ? std::make_shared() : wantAgentInfo_;
- maxScreenWantAgentInfo_ =
- maxScreenWantAgentInfo_ == nullptr ? std::make_shared() : maxScreenWantAgentInfo_;
-}
-
bool ReminderRequest::IsAlerting() const
{
return (state_ & REMINDER_STATUS_ALERTING) != 0;
@@ -1150,21 +899,6 @@ std::string ReminderRequest::GetDateTimeInfo(const time_t &timeInSecond) const
return GetTimeInfoInner(timeInSecond, TimeFormat::YMDHMS);
}
-std::string ReminderRequest::GetButtonInfo() const
-{
- std::string info = "";
- bool isFirst = true;
- for (auto button : actionButtonMap_) {
- if (!isFirst) {
- info += SEP_BUTTON_MULTI;
- }
- ActionButtonInfo buttonInfo = button.second;
- info += std::to_string(static_cast(button.first)) + SEP_BUTTON_SINGLE + buttonInfo.title;
- isFirst = false;
- }
- return info;
-}
-
uint64_t ReminderRequest::GetNowInstantMilli() const
{
time_t now;
@@ -1186,7 +920,7 @@ std::string ReminderRequest::GetShowTime(const uint64_t showTime) const
std::string ReminderRequest::GetTimeInfoInner(const time_t &timeInSecond, const TimeFormat &format) const
{
- const uint8_t dateTimeLen = 80;
+ uint8_t dateTimeLen = 80;
char dateTimeBuffer[dateTimeLen];
struct tm timeInfo;
(void)localtime_r(&timeInSecond, &timeInfo);
@@ -1413,8 +1147,8 @@ void ReminderRequest::UpdateNotificationCommon()
notificationNormalContent->SetTitle(title_);
auto notificationContent = std::make_shared(notificationNormalContent);
notificationRequest_->SetContent(notificationContent);
- if ((reminderType_ == ReminderRequest::ReminderType::TIMER) ||
- (reminderType_ == ReminderRequest::ReminderType::ALARM)) {
+ if (reminderType_ == ReminderRequest::ReminderType::TIMER
+ || reminderType_ == ReminderRequest::ReminderType::ALARM) {
notificationRequest_->SetUnremovable(true);
}
auto flags = std::make_shared();
@@ -1423,25 +1157,6 @@ void ReminderRequest::UpdateNotificationCommon()
notificationRequest_->SetFlags(flags);
}
-void ReminderRequest::UpdateNotificationBundleInfo()
-{
- std::string ownerBundleName = notificationRequest_->GetOwnerBundleName();
- if (!(ownerBundleName.empty())) {
- return;
- }
- ANSR_LOGD("ownerBundleName=%{public}s, bundleName_=%{public}s",
- ownerBundleName.c_str(), bundleName_.c_str());
- notificationRequest_->SetOwnerBundleName(bundleName_);
- notificationRequest_->SetCreatorBundleName(bundleName_);
- notificationRequest_->SetCreatorUid(uid_);
- ErrCode errCode = AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid_, userId_);
- if (errCode != ERR_OK) {
- ANSR_LOGE("GetOsAccountLocalIdFromUid fail.");
- return;
- }
- notificationRequest_->SetCreatorUserId(userId_);
-}
-
void ReminderRequest::UpdateNotificationContent(const bool &setSnooze)
{
if (notificationRequest_ == nullptr) {
@@ -1549,94 +1264,5 @@ int ReminderRequest::GetUserId(const int &uid)
AccountSA::OsAccountManager::GetOsAccountLocalIdFromUid(uid, userId);
return userId;
}
-
-void ReminderRequest::AppendValuesBucket(const sptr &reminder,
- const sptr &bundleOption, NativeRdb::ValuesBucket &values)
-{
- values.PutInt(REMINDER_ID, reminder->GetReminderId());
- values.PutString(PKG_NAME, bundleOption->GetBundleName());
- values.PutInt(USER_ID, reminder->GetUserId());
- values.PutInt(UID, reminder->GetUid());
- values.PutString(APP_LABEL, ""); // no use, compatible with old version.
- values.PutInt(REMINDER_TYPE, static_cast(reminder->GetReminderType()));
- values.PutLong(REMINDER_TIME, reminder->GetReminderTimeInMilli());
- values.PutLong(TRIGGER_TIME, reminder->GetTriggerTimeInMilli());
- values.PutLong(
- RTC_TRIGGER_TIME, reminder->GetTriggerTimeInMilli()); // no use, compatible with old version.
- values.PutLong(TIME_INTERVAL, reminder->GetTimeInterval());
- values.PutInt(SNOOZE_TIMES, reminder->GetSnoozeTimes());
- values.PutInt(DYNAMIC_SNOOZE_TIMES, reminder->GetSnoozeTimesDynamic());
- values.PutLong(RING_DURATION, reminder->GetRingDuration());
- values.PutString(IS_EXPIRED, reminder->IsExpired() ? "true" : "false");
- values.PutString(IS_ACTIVE, ""); // no use, compatible with old version.
- values.PutInt(STATE, reminder->GetState());
- values.PutString(ZONE_ID, ""); // no use, compatible with old version.
- values.PutString(HAS_SCHEDULED_TIMEOUT, ""); // no use, compatible with old version.
- values.PutString(ACTION_BUTTON_INFO, reminder->GetButtonInfo());
- values.PutInt(SLOT_ID, reminder->GetSlotType());
- values.PutInt(NOTIFICATION_ID, reminder->GetNotificationId());
- values.PutString(TITLE, reminder->GetTitle());
- values.PutString(CONTENT, reminder->GetContent());
- values.PutString(SNOOZE_CONTENT, reminder->GetSnoozeContent());
- values.PutString(EXPIRED_CONTENT, reminder->GetExpiredContent());
- auto wantAgentInfo = reminder->GetWantAgentInfo();
- if (wantAgentInfo == nullptr) {
- std::string info = "null" + ReminderRequest::SEP_WANT_AGENT + "null";
- values.PutString(AGENT, info);
- } else {
- values.PutString(AGENT, wantAgentInfo->pkgName
- + ReminderRequest::SEP_WANT_AGENT + wantAgentInfo->abilityName);
- }
- auto maxScreenWantAgentInfo = reminder->GetMaxScreenWantAgentInfo();
- if (maxScreenWantAgentInfo == nullptr) {
- std::string info = "null" + ReminderRequest::SEP_WANT_AGENT + "null";
- values.PutString(MAX_SCREEN_AGENT, info);
- } else {
- values.PutString(MAX_SCREEN_AGENT, maxScreenWantAgentInfo->pkgName
- + ReminderRequest::SEP_WANT_AGENT + maxScreenWantAgentInfo->abilityName);
- }
-}
-
-void ReminderRequest::InitDbColumns()
-{
- AddColumn(REMINDER_ID, "INTEGER PRIMARY KEY", false);
- AddColumn(PKG_NAME, "TEXT NOT NULL", false);
- AddColumn(USER_ID, "INT NOT NULL", false);
- AddColumn(UID, "INT NOT NULL", false);
- AddColumn(APP_LABEL, "TEXT", false);
- AddColumn(REMINDER_TYPE, "INT NOT NULL", false);
- AddColumn(REMINDER_TIME, "BIGINT NOT NULL", false);
- AddColumn(TRIGGER_TIME, "BIGINT NOT NULL", false);
- AddColumn(RTC_TRIGGER_TIME, "BIGINT NOT NULL", false);
- AddColumn(TIME_INTERVAL, "BIGINT NOT NULL", false);
- AddColumn(SNOOZE_TIMES, "INT NOT NULL", false);
- AddColumn(DYNAMIC_SNOOZE_TIMES, "INT NOT NULL", false);
- AddColumn(RING_DURATION, "BIGINT NOT NULL", false);
- AddColumn(IS_EXPIRED, "TEXT NOT NULL", false);
- AddColumn(IS_ACTIVE, "TEXT NOT NULL", false);
- AddColumn(STATE, "INT NOT NULL", false);
- AddColumn(ZONE_ID, "TEXT", false);
- AddColumn(HAS_SCHEDULED_TIMEOUT, "TEXT", false);
- AddColumn(ACTION_BUTTON_INFO, "TEXT", false);
- AddColumn(SLOT_ID, "INT", false);
- AddColumn(NOTIFICATION_ID, "INT NOT NULL", false);
- AddColumn(TITLE, "TEXT", false);
- AddColumn(CONTENT, "TEXT", false);
- AddColumn(SNOOZE_CONTENT, "TEXT", false);
- AddColumn(EXPIRED_CONTENT, "TEXT", false);
- AddColumn(AGENT, "TEXT", false);
- AddColumn(MAX_SCREEN_AGENT, "TEXT", false);
-}
-
-void ReminderRequest::AddColumn(
- const std::string &name, const std::string &type, const bool &isEnd)
-{
- columns.push_back(name);
- if (!isEnd) {
- sqlOfAddColumns += name + " " + type + ", ";
- } else {
- sqlOfAddColumns += name + " " + type;
- }
-}
}
}
diff --git a/frameworks/ans/native/src/reminder_request_alarm.cpp b/frameworks/ans/native/src/reminder_request_alarm.cpp
index 1bb778ea66742414abee0324b6e0bff14a37fffb..8d996322653eedd38635e138ce30884cedce4a67 100644
--- a/frameworks/ans/native/src/reminder_request_alarm.cpp
+++ b/frameworks/ans/native/src/reminder_request_alarm.cpp
@@ -16,7 +16,6 @@
#include "reminder_request_alarm.h"
#include "ans_log_wrapper.h"
-#include "reminder_store.h"
namespace OHOS {
namespace Notification {
@@ -29,11 +28,6 @@ const uint8_t ReminderRequestAlarm::MINUTES_PER_HOUR = 60;
const int8_t ReminderRequestAlarm::INVALID_INT_VALUE = -1;
const int8_t ReminderRequestAlarm::DEFAULT_SNOOZE_TIMES = 3;
-// For database recovery.
-const std::string ReminderRequestAlarm::REPEAT_DAYS_OF_WEEK = "repeat_days_of_week";
-const std::string ReminderRequestAlarm::ALARM_HOUR = "alarm_hour";
-const std::string ReminderRequestAlarm::ALARM_MINUTE = "alarm_minute";
-
ReminderRequestAlarm::ReminderRequestAlarm(uint8_t hour, uint8_t minute, const std::vector daysOfWeek)
: ReminderRequest(ReminderRequest::ReminderType::ALARM)
{
@@ -55,7 +49,7 @@ ReminderRequestAlarm::ReminderRequestAlarm(const ReminderRequestAlarm &other) :
void ReminderRequestAlarm::CheckParamValid() const
{
- if ((hour_ >= HOURS_PER_DAY) || (hour_ < 0)) {
+ if (hour_ >= HOURS_PER_DAY || hour_ < 0) {
ANSR_LOGE("setted hour is not between [0, 24)");
throw std::invalid_argument("setted hour is not between [0, 24)");
}
@@ -306,46 +300,5 @@ bool ReminderRequestAlarm::ReadFromParcel(Parcel &parcel)
ANSR_LOGD("hour_=%{public}d, minute_=%{public}d, repeatDays_=%{public}d", hour_, minute_, repeatDays_);
return true;
}
-
-void ReminderRequestAlarm::RecoverFromDb(const std::shared_ptr &resultSet)
-{
- ReminderRequest::RecoverFromDb(resultSet);
-
- // repeatDays
- repeatDays_ =
- static_cast(RecoverInt64FromDb(resultSet, REPEAT_DAYS_OF_WEEK, DbRecoveryType::INT));
-
- // hour
- hour_ =
- static_cast(RecoverInt64FromDb(resultSet, ALARM_HOUR, DbRecoveryType::INT));
-
- // minute
- minute_ =
- static_cast(RecoverInt64FromDb(resultSet, ALARM_MINUTE, DbRecoveryType::INT));
-}
-
-void ReminderRequestAlarm::AppendValuesBucket(const sptr &reminder,
- const sptr &bundleOption, NativeRdb::ValuesBucket &values)
-{
- uint8_t repeatDays = 0;
- uint8_t hour = 0;
- uint8_t minute = 0;
- if (reminder->GetReminderType() == ReminderRequest::ReminderType::ALARM) {
- ReminderRequestAlarm* alarm = static_cast(reminder.GetRefPtr());
- repeatDays = alarm->GetRepeatDay();
- hour = alarm->GetHour();
- minute = alarm->GetMinute();
- }
- values.PutInt(REPEAT_DAYS_OF_WEEK, repeatDays);
- values.PutInt(ALARM_HOUR, hour);
- values.PutInt(ALARM_MINUTE, minute);
-}
-
-void ReminderRequestAlarm::InitDbColumns()
-{
- ReminderRequest::AddColumn(REPEAT_DAYS_OF_WEEK, "INT", false);
- ReminderRequest::AddColumn(ALARM_HOUR, "INT", false);
- ReminderRequest::AddColumn(ALARM_MINUTE, "INT", true);
-}
}
}
\ No newline at end of file
diff --git a/frameworks/ans/native/src/reminder_request_calendar.cpp b/frameworks/ans/native/src/reminder_request_calendar.cpp
index b2490eb647b877e2b2aae4770c266a71babd8f66..58c260f5e45be70e4c2654d2fcb9433e6118ac54 100644
--- a/frameworks/ans/native/src/reminder_request_calendar.cpp
+++ b/frameworks/ans/native/src/reminder_request_calendar.cpp
@@ -25,18 +25,6 @@ const uint8_t ReminderRequestCalendar::JANUARY = 1;
const uint8_t ReminderRequestCalendar::DECEMBER = 12;
const uint8_t ReminderRequestCalendar::DEFAULT_SNOOZE_TIMES = 3;
-// For database recovery.
-const std::string ReminderRequestCalendar::REPEAT_DAYS = "repeat_days";
-const std::string ReminderRequestCalendar::REPEAT_MONTHS = "repeat_months";
-const std::string ReminderRequestCalendar::FIRST_DESIGNATE_YEAR = "first_designate_year";
-const std::string ReminderRequestCalendar::FIRST_DESIGNATE_MONTH = "first_designate_month";
-const std::string ReminderRequestCalendar::FIRST_DESIGNATE_DAY = "first_designate_day";
-const std::string ReminderRequestCalendar::CALENDAR_YEAR = "calendar_year";
-const std::string ReminderRequestCalendar::CALENDAR_MONTH = "calendar_month";
-const std::string ReminderRequestCalendar::CALENDAR_DAY = "calendar_day";
-const std::string ReminderRequestCalendar::CALENDAR_HOUR = "calendar_hour";
-const std::string ReminderRequestCalendar::CALENDAR_MINUTE = "calendar_minute";
-
ReminderRequestCalendar::ReminderRequestCalendar(const tm &dateTime,
const std::vector &repeatMonths, const std::vector &repeatDays)
: ReminderRequest(ReminderRequest::ReminderType::CALENDAR)
@@ -98,7 +86,7 @@ uint8_t ReminderRequestCalendar::GetDaysOfMonth(const uint16_t &year, const uint
uint8_t leapParam1 = 4;
uint8_t leapParam2 = 100;
if (month == february) {
- days = ((((year % leapParam1 == 0) && (year % leapParam2 != 0)) || (year % solarYear == 0))
+ days = ((((0 == year % leapParam1) && (0 != year % leapParam2)) || (0 == year % solarYear))
? leapMonth : nonLeapMonth);
} else {
days = daysArray[month - 1];
@@ -514,96 +502,5 @@ bool ReminderRequestCalendar::ReadFromParcel(Parcel &parcel)
}
return true;
}
-
-void ReminderRequestCalendar::RecoverFromDb(const std::shared_ptr &resultSet)
-{
- ReminderRequest::RecoverFromDb(resultSet);
-
- // repeatDay
- repeatDay_ = static_cast(RecoverInt64FromDb(resultSet, REPEAT_DAYS, DbRecoveryType::INT));
-
- // repeatMonth
- repeatMonth_ =
- static_cast(RecoverInt64FromDb(resultSet, REPEAT_MONTHS, DbRecoveryType::INT));
-
- // firstDesignateYear
- firstDesignateYear_ =
- static_cast(RecoverInt64FromDb(resultSet, FIRST_DESIGNATE_YEAR, DbRecoveryType::INT));
-
- // firstDesignateMonth
- firstDesignateMonth_ =
- static_cast(RecoverInt64FromDb(resultSet, FIRST_DESIGNATE_MONTH, DbRecoveryType::INT));
-
- // firstDesignateDay
- firstDesignateDay_ =
- static_cast(RecoverInt64FromDb(resultSet, FIRST_DESIGNATE_DAY, DbRecoveryType::INT));
-
- // year
- year_ = static_cast(RecoverInt64FromDb(resultSet, CALENDAR_YEAR, DbRecoveryType::INT));
-
- // month
- month_ = static_cast(RecoverInt64FromDb(resultSet, CALENDAR_MONTH, DbRecoveryType::INT));
-
- // day
- day_ = static_cast(RecoverInt64FromDb(resultSet, CALENDAR_DAY, DbRecoveryType::INT));
-
- // hour
- hour_ = static_cast(RecoverInt64FromDb(resultSet, CALENDAR_HOUR, DbRecoveryType::INT));
-
- // minute
- minute_ = static_cast(RecoverInt64FromDb(resultSet, CALENDAR_MINUTE, DbRecoveryType::INT));
-}
-
-void ReminderRequestCalendar::AppendValuesBucket(const sptr &reminder,
- const sptr &bundleOption, NativeRdb::ValuesBucket &values)
-{
- uint32_t repeatDay = 0;
- uint16_t repeatMonth = 0;
- uint16_t firstDesignateYear = 0;
- uint8_t firstDesignateMonth = 0;
- uint8_t firstDesignateDay = 0;
- uint16_t year = 0;
- uint8_t month = 0;
- uint8_t day = 0;
- uint8_t hour = 0;
- uint8_t minute = 0;
- if (reminder->GetReminderType() == ReminderRequest::ReminderType::CALENDAR) {
- ReminderRequestCalendar* calendar = static_cast(reminder.GetRefPtr());
- repeatDay = calendar->GetRepeatDay();
- repeatMonth = calendar->GetRepeatMonth();
- firstDesignateYear = calendar->GetFirstDesignateYear();
- firstDesignateMonth = calendar->GetFirstDesignageMonth();
- firstDesignateDay = calendar->GetFirstDesignateDay();
- year = calendar->GetYear();
- month = calendar->GetMonth();
- day = calendar->GetDay();
- hour = calendar->GetHour();
- minute = calendar->GetMinute();
- }
- values.PutInt(REPEAT_DAYS, repeatDay);
- values.PutInt(REPEAT_MONTHS, repeatMonth);
- values.PutInt(FIRST_DESIGNATE_YEAR, firstDesignateYear);
- values.PutInt(FIRST_DESIGNATE_MONTH, firstDesignateMonth);
- values.PutInt(FIRST_DESIGNATE_DAY, firstDesignateDay);
- values.PutInt(CALENDAR_YEAR, year);
- values.PutInt(CALENDAR_MONTH, month);
- values.PutInt(CALENDAR_DAY, day);
- values.PutInt(CALENDAR_HOUR, hour);
- values.PutInt(CALENDAR_MINUTE, minute);
-}
-
-void ReminderRequestCalendar::InitDbColumns()
-{
- ReminderRequest::AddColumn(REPEAT_DAYS, "INT", false);
- ReminderRequest::AddColumn(REPEAT_MONTHS, "INT", false);
- ReminderRequest::AddColumn(FIRST_DESIGNATE_YEAR, "INT", false);
- ReminderRequest::AddColumn(FIRST_DESIGNATE_MONTH, "INT", false);
- ReminderRequest::AddColumn(FIRST_DESIGNATE_DAY, "INT", false);
- ReminderRequest::AddColumn(CALENDAR_YEAR, "INT", false);
- ReminderRequest::AddColumn(CALENDAR_MONTH, "INT", false);
- ReminderRequest::AddColumn(CALENDAR_DAY, "INT", false);
- ReminderRequest::AddColumn(CALENDAR_HOUR, "INT", false);
- ReminderRequest::AddColumn(CALENDAR_MINUTE, "INT", false);
-}
}
}
\ No newline at end of file
diff --git a/frameworks/ans/native/src/reminder_store.cpp b/frameworks/ans/native/src/reminder_store.cpp
deleted file mode 100644
index 1b51a5a9f33c1f9a3d7bbe31da8d9034d9929bb4..0000000000000000000000000000000000000000
--- a/frameworks/ans/native/src/reminder_store.cpp
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * Copyright (c) 2022 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "reminder_store.h"
-
-#include
-#include
-#include
-#include
-
-#include "ability_context.h"
-#include "ans_log_wrapper.h"
-#include "reminder_request_alarm.h"
-#include "reminder_request_calendar.h"
-#include "reminder_request_timer.h"
-
-namespace OHOS {
-namespace Notification {
-namespace {
-const std::string REMINDER_DB_DIR = "/data/system_ce/ans_standard/";
-const std::string REMINDER_DB_NAME = "reminder.db";
-const std::string REMINDER_DB_TABLE = "reminder";
-const uint32_t REMINDER_RDB_VERSION = 1;
-const int32_t STATE_FAIL = -1;
-std::vector columns;
-}
-
-const int32_t ReminderStore::STATE_OK = 0;
-
-int32_t ReminderStore::ReminderStoreDataCallBack::OnCreate(NativeRdb::RdbStore &store)
-{
- ANSR_LOGD("Create table.");
- std::string CREATE_REMINDER_TABLE = "CREATE TABLE IF NOT EXISTS " + REMINDER_DB_TABLE + " ("
- + ReminderRequest::sqlOfAddColumns + ")";
- ANSR_LOGD("CreateTable:%{public}s", CREATE_REMINDER_TABLE.c_str());
- return store.ExecuteSql(CREATE_REMINDER_TABLE);
-}
-
-int32_t ReminderStore::ReminderStoreDataCallBack::OnUpgrade(
- NativeRdb::RdbStore &store, int32_t oldVersion, int32_t newVersion)
-{
- return NativeRdb::E_OK;
-}
-
-int32_t ReminderStore::Init()
-{
- ANSR_LOGD("Reminder store init.");
- int32_t errCode(STATE_FAIL);
-
- if (access(REMINDER_DB_DIR.c_str(), F_OK) != 0) {
- int createDir = mkdir(REMINDER_DB_DIR.c_str(), S_IRWXU);
- if (createDir != 0) {
- ANSR_LOGE("Failed to create directory %{public}s", REMINDER_DB_DIR.c_str());
- return errCode;
- }
- }
-
- ReminderRequest::InitDbColumns();
- ReminderRequestCalendar::InitDbColumns();
- ReminderRequestAlarm::InitDbColumns();
- columns.insert(columns.begin(),
- ReminderRequest::columns.begin(), ReminderRequest::columns.end());
-
- std::string dbConfig = REMINDER_DB_DIR + REMINDER_DB_NAME;
- NativeRdb::RdbStoreConfig config_(dbConfig);
- ReminderStoreDataCallBack rdbDataCallBack_;
- rdbStore_ = NativeRdb::RdbHelper::GetRdbStore(config_, REMINDER_RDB_VERSION, rdbDataCallBack_, errCode);
- if (rdbStore_ == nullptr) {
- ANSR_LOGE("ReminderStore init fail, errCode %{public}d.", errCode);
- return errCode;
- }
- return ReminderStore::InitData();
-}
-
-int32_t ReminderStore::InitData()
-{
- ANSR_LOGD("Reminder data init.");
- std::string deleteCondition = ReminderRequest::IS_EXPIRED + " is true";
- ReminderStore::Delete(deleteCondition);
-
- int32_t statusChangedRows = STATE_FAIL;
- NativeRdb::ValuesBucket statusValues;
- statusValues.PutInt(ReminderRequest::STATE, ReminderRequest::REMINDER_STATUS_INACTIVE);
- int32_t statusResult = rdbStore_->Update(statusChangedRows, REMINDER_DB_TABLE, statusValues);
- ANSR_LOGD("Change status to inactive, changed rows: %{public}d.", statusChangedRows);
- if (statusResult != NativeRdb::E_OK) {
- ANSR_LOGE("Init data failed.");
- return STATE_FAIL;
- }
-
- int32_t activeChangedRows = STATE_FAIL;
- NativeRdb::ValuesBucket activeValues;
- activeValues.PutString(ReminderRequest::IS_ACTIVE, "false");
- std::string activeUpdateCondition = ReminderRequest::IS_ACTIVE + " is true";
- std::vector activeWhereArgs;
- int32_t activeResult = rdbStore_->Update(
- activeChangedRows, REMINDER_DB_TABLE, activeValues, activeUpdateCondition, activeWhereArgs);
- ANSR_LOGD("Change status isActive to false, changed rows: %{public}d.", activeChangedRows);
- if (activeResult != NativeRdb::E_OK) {
- ANSR_LOGE("Init data failed.");
- return STATE_FAIL;
- }
-
- int32_t scheduledChangedRows = STATE_FAIL;
- NativeRdb::ValuesBucket scheduledValues;
- scheduledValues.PutString(ReminderRequest::HAS_SCHEDULED_TIMEOUT, "false");
- std::string scheduledUpdateCondition = ReminderRequest::HAS_SCHEDULED_TIMEOUT + " is true";
- std::vector scheduledWhereArgs;
- int32_t scheduledResult = rdbStore_->Update(
- scheduledChangedRows, REMINDER_DB_TABLE, scheduledValues, scheduledUpdateCondition, scheduledWhereArgs);
- ANSR_LOGD("Change status has_ScheduledTimeout to false, changed rows: %{public}d.", scheduledChangedRows);
- if (scheduledResult != NativeRdb::E_OK) {
- ANSR_LOGE("Init data failed.");
- return STATE_FAIL;
- }
- return ReminderStore::STATE_OK;
-}
-
-int32_t ReminderStore::Delete(int32_t reminderId)
-{
- std::string deleteCondition = ReminderRequest::REMINDER_ID
- + " = " + std::to_string(reminderId);
- return ReminderStore::Delete(deleteCondition);
-}
-
-int32_t ReminderStore::DeleteUser(int32_t userId)
-{
- std::string deleteCondition = ReminderRequest::USER_ID + " = " + std::to_string(userId);
- return ReminderStore::Delete(deleteCondition);
-}
-
-int32_t ReminderStore::Delete(const std::string &pkg, int32_t userId)
-{
- std::string deleteCondition = ReminderRequest::PKG_NAME + " = " + pkg + " and "
- + ReminderRequest::USER_ID + " = " + std::to_string(userId);
- return ReminderStore::Delete(deleteCondition);
-}
-
-int32_t ReminderStore::Delete(const std::string &deleteCondition)
-{
- if (rdbStore_ == nullptr) {
- ANSR_LOGE("Rdb store is not initialized.");
- return STATE_FAIL;
- }
- int32_t deletedRows = STATE_FAIL;
- std::vector whereArgs;
- int32_t result = rdbStore_->Delete(deletedRows, REMINDER_DB_TABLE, deleteCondition, whereArgs);
- if (result != NativeRdb::E_OK) {
- ANSR_LOGE("Delete operation failed, deleteConditon: %{public}s," \
- "result: %{public}d.", deleteCondition.c_str(), result);
- }
- ANSR_LOGD("Delete operation done, deleteConditon: %{public}s," \
- "deleted rows: %{public}d.", deleteCondition.c_str(), deletedRows);
- return deletedRows;
-}
-
-int64_t ReminderStore::UpdateOrInsert(
- const sptr &reminder, const sptr &bundleOption)
-{
- if (reminder->GetReminderType() == ReminderRequest::ReminderType::TIMER) {
- ANSR_LOGI("Countdown not support persist.");
- return STATE_FAIL;
- }
- int64_t isSuccess = STATE_FAIL;
- if (rdbStore_ == nullptr) {
- ANSR_LOGE("Rdb store is not initialized.");
- return isSuccess;
- }
- if (bundleOption == nullptr) {
- ANSR_LOGE("BundleOption is null.");
- return isSuccess;
- }
- if (IsReminderExist(reminder)) {
- isSuccess = Update(reminder, bundleOption);
- } else {
- isSuccess = Insert(reminder, bundleOption);
- }
- return isSuccess;
-}
-
-int64_t ReminderStore::Insert(
- const sptr &reminder, const sptr &bundleOption)
-{
- int64_t rowId = STATE_FAIL;
- NativeRdb::ValuesBucket values;
- ReminderStore::GenerateData(reminder, bundleOption, values);
- int32_t result = rdbStore_->Insert(rowId, REMINDER_DB_TABLE, values);
- if (result != NativeRdb::E_OK) {
- ANSR_LOGE("Insert operation failed, result: %{public}d, reminderId=%{public}d.",
- result, reminder->GetReminderId());
- return result;
- }
- ANSR_LOGD("Insert successfully, reminderId=%{public}d.", reminder->GetReminderId());
- return result;
-}
-
-int64_t ReminderStore::Update(
- const sptr &reminder, const sptr &bundleOption)
-{
- int32_t changedRows = STATE_FAIL;
- NativeRdb::ValuesBucket values;
- ReminderStore::GenerateData(reminder, bundleOption, values);
- std::string updateCondition = ReminderRequest::REMINDER_ID
- + " = " + std::to_string(reminder->GetReminderId());
- std::vector whereArgs;
- int32_t result = rdbStore_->Update(changedRows, REMINDER_DB_TABLE, values, updateCondition, whereArgs);
- if ((result != NativeRdb::E_OK) || (changedRows <= 0)) {
- ANSR_LOGE("Update operation failed, result: %{public}d, updated rows: %{public}d, reminderId=%{public}d.",
- result, changedRows, reminder->GetReminderId());
- return result;
- }
- ANSR_LOGD("Update successfully, updated rows: %{public}d, reminderId=%{public}d.",
- changedRows, reminder->GetReminderId());
- return result;
-}
-
-bool ReminderStore::IsReminderExist(const sptr &reminder)
-{
- std::string queryCondition = "select " + ReminderRequest::REMINDER_ID
- + " from " + REMINDER_DB_TABLE + " where "
- + ReminderRequest::REMINDER_ID + " = " + std::to_string(reminder->GetReminderId());
- std::vector whereArgs;
- std::unique_ptr queryResultSet = rdbStore_->QuerySql(queryCondition, whereArgs);
- if (queryResultSet == nullptr) {
- ANSR_LOGE("QueryResultSet is null.");
- return false;
- }
- int32_t resultNum;
- queryResultSet->GetRowCount(resultNum);
- if (resultNum == 0) {
- return false;
- }
- return true;
-}
-
-std::shared_ptr ReminderStore::Query(const std::string &queryCondition) const
-{
- std::unique_ptr queryResultSet;
- if (rdbStore_ == nullptr) {
- ANSR_LOGE("Rdb store is not initialized.");
- return queryResultSet;
- }
- std::vector whereArgs;
- queryResultSet = rdbStore_->QuerySql(queryCondition, whereArgs);
- return queryResultSet;
-}
-
-uint8_t ReminderStore::GetColumnIndex(const std::string& name)
-{
- uint8_t index = 0;
- for (auto it = columns.begin(); it != columns.end(); ++it) {
- if (name == (*it)) {
- break;
- }
- index++;
- }
- return index;
-}
-
-int32_t ReminderStore::GetMaxId()
-{
- if (rdbStore_ == nullptr) {
- ANSR_LOGE("Rdb store is not initialized.");
- return STATE_FAIL;
- }
- std::string queryCondition = "select " + ReminderRequest::REMINDER_ID
- + " from " + REMINDER_DB_TABLE + " order by "
- + ReminderRequest::REMINDER_ID + " desc";
- std::shared_ptr queryResultSet = ReminderStore::Query(queryCondition);
- if (queryResultSet == nullptr) {
- ANSR_LOGE("QueryResultSet is null.");
- return STATE_FAIL;
- }
- int32_t resultNum;
- queryResultSet->GetRowCount(resultNum);
- if (resultNum == 0) {
- ANSR_LOGI("QueryResultSet is zero.");
- return STATE_FAIL;
- }
- queryResultSet->GoToNextRow();
- int32_t maxId = STATE_FAIL;
- int32_t result = queryResultSet->GetInt(0, maxId);
- if (result != NativeRdb::E_OK) {
- ANSR_LOGE("Query operation failed, result %{public}d.", result);
- }
- ANSR_LOGD("MaxId: %{public}d.", maxId);
- return maxId;
-}
-
-std::vector> ReminderStore::GetAllValidReminders()
-{
- std::string queryCondition = "select * from " + REMINDER_DB_TABLE + " where "
- + ReminderRequest::IS_EXPIRED + " is false order by "
- + ReminderRequest::TRIGGER_TIME + " asc";
- ANSR_LOGD("Get all reminders");
- return GetReminders(queryCondition);
-}
-
-std::vector> ReminderStore::GetReminders(const std::string &queryCondition)
-{
- std::vector> reminders;
- if (rdbStore_ == nullptr) {
- ANSR_LOGE("Rdb store is not initialized.");
- return reminders;
- }
- std::shared_ptr queryResultSet = Query(queryCondition);
- if (queryResultSet == nullptr) {
- return reminders;
- }
- bool isAtLastRow = false;
- queryResultSet->IsAtLastRow(isAtLastRow);
- while (!isAtLastRow) {
- queryResultSet->GoToNextRow();
- sptr reminder;
- reminder = BuildReminder(queryResultSet);
- reminders.push_back(reminder);
- queryResultSet->IsAtLastRow(isAtLastRow);
- }
- ANSR_LOGD("Size=%{public}d", reminders.size());
- return reminders;
-}
-
-sptr ReminderStore::BuildReminder(const std::shared_ptr &resultSet)
-{
- int32_t reminderType;
- int32_t reminderId;
- resultSet->GetInt(ReminderStore::GetColumnIndex(ReminderRequest::REMINDER_TYPE), reminderType);
- resultSet->GetInt(ReminderStore::GetColumnIndex(ReminderRequest::REMINDER_ID), reminderId);
-
- sptr reminder = nullptr;
- switch (reminderType) {
- case (static_cast(ReminderRequest::ReminderType::TIMER)): {
- reminder = new ReminderRequestTimer(reminderId);
- break;
- }
- case (static_cast(ReminderRequest::ReminderType::CALENDAR)): {
- reminder = new ReminderRequestCalendar(reminderId);
- break;
- }
- case (static_cast(ReminderRequest::ReminderType::ALARM)): {
- reminder = new ReminderRequestAlarm(reminderId);
- break;
- }
- default: {
- ANSR_LOGE("ReminderType from database is error, reminderType %{public}d.", reminderType);
- break;
- }
- }
- if (reminder != nullptr) {
- reminder->RecoverFromDb(resultSet);
- ANSR_LOGI("BuildReminder success.");
- } else {
- ANSR_LOGW("BuildReminder fail.");
- }
- return reminder;
-}
-
-bool ReminderStore::GetBundleOption(const int32_t &reminderId, sptr &bundleOption) const
-{
- std::string queryCondition = "select " + ReminderRequest::PKG_NAME + ", "
- + ReminderRequest::UID + " from " + REMINDER_DB_TABLE + " where "
- + ReminderRequest::REMINDER_ID + "=" + std::to_string(reminderId);
- std::shared_ptr queryResultSet = Query(queryCondition);
- if (queryResultSet == nullptr) {
- return false;
- }
- bool isAtLastRow = false;
- queryResultSet->IsAtLastRow(isAtLastRow);
- if (isAtLastRow) {
- return false;
- }
- queryResultSet->GoToNextRow();
- std::string pkgName;
- GetStringVal(queryResultSet, ReminderRequest::PKG_NAME, pkgName);
- int32_t uid;
- GetInt32Val(queryResultSet, ReminderRequest::UID, uid);
- bundleOption->SetBundleName(pkgName);
- bundleOption->SetUid(uid);
- return true;
-}
-
-void ReminderStore::GetInt32Val(std::shared_ptr &resultSet,
- const std::string &name, int32_t &value) const
-{
- int32_t columnIndex;
- resultSet->GetColumnIndex(name, columnIndex);
- resultSet->GetInt(columnIndex, value);
-}
-
-void ReminderStore::GetStringVal(std::shared_ptr &resultSet,
- const std::string &name, std::string &value) const
-{
- int32_t columnIndex;
- resultSet->GetColumnIndex(name, columnIndex);
- resultSet->GetString(columnIndex, value);
-}
-
-void ReminderStore::GenerateData(const sptr &reminder,
- const sptr &bundleOption, NativeRdb::ValuesBucket &values) const
-{
- ReminderRequest::AppendValuesBucket(reminder, bundleOption, values);
- ReminderRequestCalendar::AppendValuesBucket(reminder, bundleOption, values);
- ReminderRequestAlarm::AppendValuesBucket(reminder, bundleOption, values);
-}
-} // namespace Notification
-} // namespace OHOS
diff --git a/frameworks/ans/native/test/unittest/BUILD.gn b/frameworks/ans/native/test/unittest/BUILD.gn
index 5822ce2fce71617b3298d3636469fb89ed9ffcf1..6ff225e5b24ee98b492a4f648358cabc949577f3 100644
--- a/frameworks/ans/native/test/unittest/BUILD.gn
+++ b/frameworks/ans/native/test/unittest/BUILD.gn
@@ -1,4 +1,4 @@
-# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
@@ -47,18 +47,17 @@ ohos_unittest("ans_reminder_unit_test") {
external_deps = [
"ability_base:want",
- "ability_base:zuri",
"ability_runtime:wantagent_innerkits",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"bytrace_standard:bytrace_core",
"ces_standard:cesfwk_innerkits",
"distributeddatamgr:distributeddata_inner",
+ "dmsfwk_standard:zuri",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"multimedia_image_standard:image_native",
- "native_appdatamgr:native_rdb",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
diff --git a/frameworks/ans/test/moduletest/BUILD.gn b/frameworks/ans/test/moduletest/BUILD.gn
index ff4682817592e928983eaeb80a5b3ef4deec72b6..de3b5012a106ad6a78231fc4c9004bfa7f14438c 100644
--- a/frameworks/ans/test/moduletest/BUILD.gn
+++ b/frameworks/ans/test/moduletest/BUILD.gn
@@ -54,7 +54,6 @@ ohos_moduletest("ans_fw_module_test") {
"mock/blob.cpp",
"mock/distributed_kv_data_manager.cpp",
"mock/mock_bundle_manager.cpp",
- "mock/mock_bundle_manager_helper.cpp",
"mock/mock_bundle_mgr_proxy.cpp",
"mock/mock_change_notification.cpp",
"mock/mock_common_event_data.cpp",
@@ -81,18 +80,17 @@ ohos_moduletest("ans_fw_module_test") {
external_deps = [
"ability_base:want",
- "ability_base:zuri",
"ability_runtime:wantagent_innerkits",
"access_token:libaccesstoken_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"ces_standard:cesfwk_innerkits",
"distributeddatamgr:distributeddata_inner",
+ "dmsfwk_standard:zuri",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"multimedia_image_standard:image_native",
- "native_appdatamgr:native_rdb",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
@@ -129,7 +127,6 @@ ohos_moduletest("ans_innerkits_module_publish_test") {
"mock/blob.cpp",
"mock/distributed_kv_data_manager.cpp",
"mock/mock_bundle_manager.cpp",
- "mock/mock_bundle_manager_helper.cpp",
"mock/mock_bundle_mgr_proxy.cpp",
"mock/mock_change_notification.cpp",
"mock/mock_common_event_data.cpp",
@@ -157,18 +154,17 @@ ohos_moduletest("ans_innerkits_module_publish_test") {
external_deps = [
"ability_base:base",
"ability_base:want",
- "ability_base:zuri",
"ability_runtime:wantagent_innerkits",
"access_token:libaccesstoken_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"ces_standard:cesfwk_innerkits",
"distributeddatamgr:distributeddata_inner",
+ "dmsfwk_standard:zuri",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"multimedia_image_standard:image_native",
- "native_appdatamgr:native_rdb",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
@@ -205,7 +201,6 @@ ohos_moduletest("ans_innerkits_module_slot_test") {
"mock/blob.cpp",
"mock/distributed_kv_data_manager.cpp",
"mock/mock_bundle_manager.cpp",
- "mock/mock_bundle_manager_helper.cpp",
"mock/mock_bundle_mgr_proxy.cpp",
"mock/mock_change_notification.cpp",
"mock/mock_common_event_data.cpp",
@@ -232,18 +227,17 @@ ohos_moduletest("ans_innerkits_module_slot_test") {
external_deps = [
"ability_base:want",
- "ability_base:zuri",
"ability_runtime:wantagent_innerkits",
"access_token:libaccesstoken_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"ces_standard:cesfwk_innerkits",
"distributeddatamgr:distributeddata_inner",
+ "dmsfwk_standard:zuri",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"multimedia_image_standard:image_native",
- "native_appdatamgr:native_rdb",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
@@ -280,7 +274,6 @@ ohos_moduletest("ans_innerkits_module_setting_test") {
"mock/blob.cpp",
"mock/distributed_kv_data_manager.cpp",
"mock/mock_bundle_manager.cpp",
- "mock/mock_bundle_manager_helper.cpp",
"mock/mock_bundle_mgr_proxy.cpp",
"mock/mock_change_notification.cpp",
"mock/mock_common_event_data.cpp",
@@ -307,18 +300,17 @@ ohos_moduletest("ans_innerkits_module_setting_test") {
external_deps = [
"ability_base:want",
- "ability_base:zuri",
"ability_runtime:wantagent_innerkits",
"access_token:libaccesstoken_sdk",
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"ces_standard:cesfwk_innerkits",
"distributeddatamgr:distributeddata_inner",
+ "dmsfwk_standard:zuri",
"eventhandler:libeventhandler",
"hiviewdfx_hilog_native:libhilog",
"ipc:ipc_core",
"multimedia_image_standard:image_native",
- "native_appdatamgr:native_rdb",
"safwk:system_ability_fwk",
"samgr_standard:samgr_proxy",
]
@@ -341,8 +333,8 @@ group("moduletest") {
deps += [
# ":ReminderAgentJsTest",
# ":ans_fw_module_test",
- # ":ans_innerkits_module_publish_test",
- # ":ans_innerkits_module_setting_test",
- # ":ans_innerkits_module_slot_test",
+ ":ans_innerkits_module_publish_test",
+ ":ans_innerkits_module_setting_test",
+ ":ans_innerkits_module_slot_test",
]
}
diff --git a/frameworks/ans/test/moduletest/ReminderHelperTest.js b/frameworks/ans/test/moduletest/ReminderHelperTest.js
index c3952cb152c551c671dd6b4c2a807645af431687..8f759bb5aeaa397729cee4bc6144c64c3aa3802d 100644
--- a/frameworks/ans/test/moduletest/ReminderHelperTest.js
+++ b/frameworks/ans/test/moduletest/ReminderHelperTest.js
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -108,7 +108,8 @@ describe("ReminderHelperTest", function () {
*/
it("testReminderHelper003", 0, async function (done) {
function reminderCallback(err, data) {
- expect(true).assertEqual(true);
+ let i = 0;
+ expect(0).assertEqual(i);
}
reminderAgent.addNotificationSlot(0, reminderCallback);
done();
@@ -244,13 +245,14 @@ describe("ReminderHelperTest", function () {
reminderType: reminderAgent.ReminderType.REMINDER_TYPE_TIMER,
triggerTimeInSeconds: 3
}
+ let id = 1;
let publishlength = -1;
let cancellength = -1;
let firstdiff = -1;
reminderAgent.publishReminder(timer).then(() => {
reminderAgent.getValidReminders().then((reminders) => {
publishlength=reminders.length
- reminderAgent.cancelReminder(0).then(() => {
+ reminderAgent.cancelReminder(id).then(() => {
reminderAgent.getValidReminders().then((reminders) => {
cancellength = reminders.length
firstdiff = publishlength - cancellength;
@@ -317,8 +319,10 @@ describe("ReminderHelperTest", function () {
reminderAgent.getValidReminders((err, reminders) => {
cancellength = reminders.length;
firstdiff = publishlength - cancellength;
- if (firstdiff === 0 || firstdiff === 1) {
+ if (firstdiff === 0) {
expect(0).assertEqual(firstdiff);
+ } else if (firstdiff === 1) {
+ expect(1).assertEqual(firstdiff);
}
});
});
@@ -353,8 +357,10 @@ describe("ReminderHelperTest", function () {
reminderAgent.getValidReminders((err, reminders) => {
cancellength = reminders.length;
firstdiff = publishlength - cancellength;
- if (firstdiff === 0 || firstdiff === 1) {
+ if (firstdiff === 0) {
expect(0).assertEqual(firstdiff);
+ } else if (firstdiff === 1) {
+ expect(1).assertEqual(firstdiff);
}
});
});
@@ -840,7 +846,7 @@ describe("ReminderHelperTest", function () {
slotType:3
}
reminderAgent.publishReminder(calendar).then((reminderId) => {
- expect(typeof(reminderId) === 'number').assertEqual(true);
+ expect(typeof(reminderId)).assertEqual('number');
});
done();
})
diff --git a/frameworks/ans/test/moduletest/ans_fw_module_test.cpp b/frameworks/ans/test/moduletest/ans_fw_module_test.cpp
index e5fec4ec012c82b7df8eff17d3e04206cdaabbb3..e7d017b0b70177dc3f4df348bf857d396e97a5e1 100644
--- a/frameworks/ans/test/moduletest/ans_fw_module_test.cpp
+++ b/frameworks/ans/test/moduletest/ans_fw_module_test.cpp
@@ -28,7 +28,6 @@
#include "ans_manager_proxy.h"
#include "common_event_manager.h"
#include "common_event_support.h"
-#include "datetime_ex.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "mock_ipc_skeleton.h"
@@ -64,7 +63,6 @@ const std::string KVSTORE_PREFERENCES_STORE_ID = "distributed_preferences";
const std::string KVSTORE_SCREEN_STATUS_STORE_ID = "distributed_screen_status";
constexpr int UID = 1;
-constexpr int USER_ID = 0;
constexpr int CANCEL_REASON_DELETE = 2;
constexpr int APP_CANCEL_REASON_DELETE = 8;
constexpr int APP_CANCEL_ALL_REASON_DELETE = 9;
@@ -474,9 +472,7 @@ public:
void Parse(std::list> events)
{
- GTEST_LOG_(INFO) << "TestAnsSubscriber::Parse event size=" << events.size();
for (auto event : events) {
- GTEST_LOG_(INFO) << "TestAnsSubscriber::Parse event type=" << static_cast(event->GetType());
if (event->GetType() == SubscriberEventType::ON_SUBSCRIBERESULT) {
waitOnSubscriber_ = true;
} else if (event->GetType() == SubscriberEventType::ON_CONSUMED) {
@@ -674,8 +670,7 @@ HWTEST_F(AnsFWModuleTest, ANS_FW_MT_FlowControl_00100, Function | MediumTest | L
int32_t notificationIdInt = i;
if (i < MAX_ACTIVE_NUM_PERSECOND) {
std::stringstream stream;
- stream << KEY_SPLITER << USER_ID << KEY_SPLITER << UID << KEY_SPLITER
- << notificationLabel << KEY_SPLITER << notificationIdInt;
+ stream << KEY_SPLITER << UID << KEY_SPLITER << notificationLabel << KEY_SPLITER << notificationIdInt;
std::string notificationKey = stream.str();
NotificationSorting sorting;
EXPECT_EQ(eventParser.GetOnConsumedReq()[i]->GetLabel().c_str(), notificationLabel);
@@ -731,7 +726,7 @@ HWTEST_F(AnsFWModuleTest, ANS_FW_MT_RemoveNotificaitonsByKey_00100, Function | M
EXPECT_EQ(eventParser.GetOnConsumedReq()[0]->GetLabel().c_str(), NOTIFICATION_LABEL_0);
EXPECT_EQ(eventParser.GetOnConsumedReq()[0]->GetId(), 0);
std::stringstream stream;
- stream << KEY_SPLITER << USER_ID << KEY_SPLITER << UID << KEY_SPLITER << NOTIFICATION_LABEL_0 << KEY_SPLITER << 0;
+ stream << KEY_SPLITER << UID << KEY_SPLITER << NOTIFICATION_LABEL_0 << KEY_SPLITER << 0;
std::string notificationKey = stream.str();
NotificationSorting sorting;
EXPECT_EQ(eventParser.GetOnCanceledReq()[0]->GetKey(), notificationKey);
@@ -821,7 +816,7 @@ HWTEST_F(AnsFWModuleTest, ANS_FW_MT_RemoveNotificaitons_00100, Function | Medium
eventParser.Parse(events);
EXPECT_TRUE(eventParser.GetWaitOnConsumed());
SleepForFC();
- EXPECT_EQ(NotificationHelper::RemoveNotifications(USER_ID), ERR_OK);
+ EXPECT_EQ(NotificationHelper::RemoveNotifications(), ERR_OK);
std::vector> notifications;
EXPECT_EQ(NotificationHelper::GetAllActiveNotifications(notifications), ERR_OK);
EXPECT_EQ((int)notifications.size(), (int)0);
@@ -1004,7 +999,7 @@ HWTEST_F(AnsFWModuleTest, ANS_FW_MT_CancelNotificationById_00100, Function | Med
EXPECT_EQ(eventParser.GetOnConsumedReq()[0]->GetLabel().c_str(), NOTIFICATION_LABEL_0);
EXPECT_EQ(eventParser.GetOnConsumedReq()[0]->GetId(), 1);
std::stringstream stream;
- stream << KEY_SPLITER << USER_ID << KEY_SPLITER << UID << KEY_SPLITER << NOTIFICATION_LABEL_0 << KEY_SPLITER << 1;
+ stream << KEY_SPLITER << UID << KEY_SPLITER << NOTIFICATION_LABEL_0 << KEY_SPLITER << 1;
std::string notificationKey = stream.str();
NotificationSorting sorting;
EXPECT_EQ(eventParser.GetOnCanceledReq()[0]->GetKey(), notificationKey);
@@ -1099,7 +1094,7 @@ HWTEST_F(AnsFWModuleTest, ANS_FW_MT_CancelAllNotifications_00100, Function | Med
EXPECT_EQ(eventParser.GetOnConsumedReq()[0]->GetLabel().c_str(), NOTIFICATION_LABEL_0);
EXPECT_EQ(eventParser.GetOnConsumedReq()[0]->GetId(), 0);
std::stringstream stream0;
- stream0 << KEY_SPLITER << USER_ID << KEY_SPLITER << UID << KEY_SPLITER << NOTIFICATION_LABEL_0 << KEY_SPLITER << 0;
+ stream0 << KEY_SPLITER << UID << KEY_SPLITER << NOTIFICATION_LABEL_0 << KEY_SPLITER << 0;
std::string notificationKey0 = stream0.str();
NotificationSorting sorting0;
EXPECT_EQ(eventParser.GetOnCanceledReq()[0]->GetKey(), notificationKey0);
@@ -1111,7 +1106,7 @@ HWTEST_F(AnsFWModuleTest, ANS_FW_MT_CancelAllNotifications_00100, Function | Med
EXPECT_EQ(eventParser.GetOnConsumedReq()[1]->GetLabel().c_str(), NOTIFICATION_LABEL_1);
EXPECT_EQ(eventParser.GetOnConsumedReq()[1]->GetId(), 1);
std::stringstream stream1;
- stream1 << KEY_SPLITER << USER_ID << KEY_SPLITER << UID << KEY_SPLITER << NOTIFICATION_LABEL_1 << KEY_SPLITER << 1;
+ stream1 << KEY_SPLITER << UID << KEY_SPLITER << NOTIFICATION_LABEL_1 << KEY_SPLITER << 1;
std::string notificationKey1 = stream1.str();
NotificationSorting sorting1;
EXPECT_EQ(eventParser.GetOnCanceledReq()[1]->GetKey(), notificationKey1);
@@ -1792,7 +1787,7 @@ HWTEST_F(AnsFWModuleTest, DistributedNotification_Publish_00300, Function | Medi
ASSERT_EQ(NotificationHelper::PublishNotification(request), ERR_OK);
ASSERT_EQ(pointer->GetEntries(DistributedKv::Key(""), entries), DistributedKv::Status::SUCCESS);
DistributedKv::Entry outEntry;
- ASSERT_EQ(GetRequestInDistributedEntryList(request, entries, outEntry), true);
+ ASSERT_EQ(GetRequestInDistributedEntryList(request, entries, outEntry), false);
AppExecFwk::MockSetDistributedNotificationEnabled(true);
SleepForFC();
}
@@ -1915,7 +1910,7 @@ HWTEST_F(AnsFWModuleTest, DistributedNotification_Remove_00200, Function | Mediu
ASSERT_EQ(pointer->GetEntries(DistributedKv::Key(""), entries), DistributedKv::Status::SUCCESS);
ASSERT_EQ(GetRequestInDistributedEntryList(request, entries, outEntry), true);
- ASSERT_EQ(NotificationHelper::RemoveNotifications(USER_ID), ERR_OK);
+ ASSERT_EQ(NotificationHelper::RemoveNotifications(), ERR_OK);
ASSERT_EQ(pointer->GetEntries(DistributedKv::Key(""), entries), DistributedKv::Status::SUCCESS);
ASSERT_EQ(entries.size(), std::size_t(0));
SleepForFC();
@@ -1984,7 +1979,7 @@ HWTEST_F(AnsFWModuleTest, DistributedNotification_Subscribe_00100, Function | Me
EventParser parser1;
parser1.Parse(subscriber.GetEvents());
- auto notificationList = parser1.GetOnConsumedWithSortingMapReq();
+ auto notificationList = parser1.GetOnConsumedReq();
EXPECT_NE(notificationList.size(), std::size_t(0));
std::shared_ptr outNotification;
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
@@ -1995,7 +1990,7 @@ HWTEST_F(AnsFWModuleTest, DistributedNotification_Subscribe_00100, Function | Me
EventParser parser2;
parser2.Parse(subscriber.GetEvents());
- notificationList = parser2.GetOnConsumedWithSortingMapReq();
+ notificationList = parser2.GetOnConsumedReq();
EXPECT_NE(notificationList.size(), std::size_t(0));
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
subscriber.ClearEvents();
@@ -2045,7 +2040,7 @@ HWTEST_F(AnsFWModuleTest, DistributedNotification_Subscribe_00200, Function | Me
EventParser parser1;
parser1.Parse(subscriber.GetEvents());
- auto notificationList = parser1.GetOnConsumedWithSortingMapReq();
+ auto notificationList = parser1.GetOnConsumedReq();
EXPECT_NE(notificationList.size(), std::size_t(0));
std::shared_ptr outNotification;
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
@@ -2119,12 +2114,12 @@ HWTEST_F(AnsFWModuleTest, DefaultRemindPolicy_00100, Function | MediumTest | Lev
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
+
EXPECT_EQ(NotificationHelper::PublishNotification(request), ERR_OK);
- SleepForFC();
EventParser parser;
parser.Parse(subscriber.GetEvents());
- auto notificationList = parser.GetOnConsumedWithSortingMapReq();
+ auto notificationList = parser.GetOnConsumedReq();
std::shared_ptr outNotification;
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
EXPECT_EQ(outNotification->GetRemindType(), NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND);
@@ -2150,12 +2145,12 @@ HWTEST_F(AnsFWModuleTest, DefaultRemindPolicy_00200, Function | MediumTest | Lev
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
+
EXPECT_EQ(NotificationHelper::PublishNotification(request), ERR_OK);
- SleepForFC();
EventParser parser;
parser.Parse(subscriber.GetEvents());
- auto notificationList = parser.GetOnConsumedWithSortingMapReq();
+ auto notificationList = parser.GetOnConsumedReq();
std::shared_ptr outNotification;
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
EXPECT_EQ(outNotification->GetRemindType(), NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND);
@@ -2181,12 +2176,12 @@ HWTEST_F(AnsFWModuleTest, DefaultRemindPolicy_00300, Function | MediumTest | Lev
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
+
EXPECT_EQ(NotificationHelper::PublishNotification(request), ERR_OK);
- SleepForFC();
EventParser parser;
parser.Parse(subscriber.GetEvents());
- auto notificationList = parser.GetOnConsumedWithSortingMapReq();
+ auto notificationList = parser.GetOnConsumedReq();
std::shared_ptr outNotification;
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
EXPECT_EQ(outNotification->GetRemindType(), NotificationConstant::RemindType::DEVICE_IDLE_REMIND);
@@ -2212,12 +2207,12 @@ HWTEST_F(AnsFWModuleTest, DefaultRemindPolicy_00400, Function | MediumTest | Lev
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
+
EXPECT_EQ(NotificationHelper::PublishNotification(request), ERR_OK);
- SleepForFC();
EventParser parser;
parser.Parse(subscriber.GetEvents());
- auto notificationList = parser.GetOnConsumedWithSortingMapReq();
+ auto notificationList = parser.GetOnConsumedReq();
std::shared_ptr outNotification;
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
EXPECT_EQ(outNotification->GetRemindType(), NotificationConstant::RemindType::DEVICE_IDLE_DONOT_REMIND);
@@ -2246,23 +2241,21 @@ HWTEST_F(AnsFWModuleTest, DefaultRemindPolicy_00500, Function | MediumTest | Lev
PublishCommonEventScreenStatus(true);
+ TestAnsSubscriber subscriber;
+ EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
DistributedKv::AppId appId = {.appId = KVSTORE_APP_ID};
- DistributedKv::StoreId storeId = {.storeId = KVSTORE_NOTIFICATION_STORE_ID};
+ DistributedKv::StoreId storeId = {.storeId = KVSTORE_SCREEN_STATUS_STORE_ID};
std::shared_ptr pointer =
DistributedKv::AnsTestSingleKvStore::GetMockKvStorePointer(appId, storeId);
- TestAnsSubscriber subscriber;
- EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
-
DistributedKv::Key key(GenerateDistributedKey(request, REMOTE_DEVICE_ID));
DistributedKv::Value value(jsonString);
pointer->InsertDataToDoCallback(key, value);
SleepForFC();
- SleepForFC();
EventParser parser;
parser.Parse(subscriber.GetEvents());
- auto notificationList = parser.GetOnConsumedWithSortingMapReq();
+ auto notificationList = parser.GetOnConsumedReq();
std::shared_ptr outNotification;
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
EXPECT_EQ(outNotification->GetRemindType(), NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND);
@@ -2291,14 +2284,13 @@ HWTEST_F(AnsFWModuleTest, DefaultRemindPolicy_00600, Function | MediumTest | Lev
PublishCommonEventScreenStatus(false);
+ TestAnsSubscriber subscriber;
+ EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
DistributedKv::AppId appId = {.appId = KVSTORE_APP_ID};
- DistributedKv::StoreId storeId = {.storeId = KVSTORE_NOTIFICATION_STORE_ID};
+ DistributedKv::StoreId storeId = {.storeId = KVSTORE_SCREEN_STATUS_STORE_ID};
std::shared_ptr pointer =
DistributedKv::AnsTestSingleKvStore::GetMockKvStorePointer(appId, storeId);
- TestAnsSubscriber subscriber;
- EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
-
DistributedKv::Key key(GenerateDistributedKey(request, REMOTE_DEVICE_ID));
DistributedKv::Value value(jsonString);
pointer->InsertDataToDoCallback(key, value);
@@ -2306,7 +2298,7 @@ HWTEST_F(AnsFWModuleTest, DefaultRemindPolicy_00600, Function | MediumTest | Lev
EventParser parser;
parser.Parse(subscriber.GetEvents());
- auto notificationList = parser.GetOnConsumedWithSortingMapReq();
+ auto notificationList = parser.GetOnConsumedReq();
std::shared_ptr outNotification;
EXPECT_EQ(GetRequestInNotificationList(request, notificationList, outNotification), true);
EXPECT_EQ(outNotification->GetRemindType(), NotificationConstant::RemindType::DEVICE_IDLE_DONOT_REMIND);
@@ -2322,11 +2314,7 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PulbishContinuousTask_07100, Function
IPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID);
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
-
- std::shared_ptr implContent = std::make_shared();
- std::shared_ptr content = std::make_shared(implContent);
NotificationRequest req(0);
- req.SetContent(content);
req.SetLabel(NOTIFICATION_LABEL_0);
EXPECT_EQ(NotificationHelper::PublishContinuousTaskNotification(req), ERR_OK);
SleepForFC();
@@ -2361,11 +2349,7 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PulbishContinuousTask_07200, Function
IPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID);
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
-
- std::shared_ptr implContent = std::make_shared();
- std::shared_ptr content = std::make_shared(implContent);
NotificationRequest req(0);
- req.SetContent(content);
req.SetLabel(NOTIFICATION_LABEL_0);
EXPECT_EQ(NotificationHelper::PublishContinuousTaskNotification(req), ERR_OK);
SleepForFC();
@@ -2402,11 +2386,7 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PulbishContinuousTask_07300, Function
IPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID);
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
-
- std::shared_ptr implContent = std::make_shared();
- std::shared_ptr content = std::make_shared(implContent);
NotificationRequest req(0);
- req.SetContent(content);
req.SetLabel(NOTIFICATION_LABEL_0);
EXPECT_EQ(NotificationHelper::PublishContinuousTaskNotification(req), ERR_OK);
SleepForFC();
@@ -2439,10 +2419,7 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PulbishContinuousTask_07300, Function
HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PulbishContinuousTask_07400, Function | MediumTest | Level1)
{
- std::shared_ptr implContent = std::make_shared();
- std::shared_ptr content = std::make_shared(implContent);
NotificationRequest req(0);
- req.SetContent(content);
req.SetLabel(NOTIFICATION_LABEL_0);
EXPECT_EQ(NotificationHelper::PublishContinuousTaskNotification(req), (int)ERR_ANS_NOT_SYSTEM_SERVICE);
}
@@ -2489,10 +2466,7 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PulbishContinuousTask_07600, Function
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
- std::shared_ptr implContent = std::make_shared();
- std::shared_ptr content = std::make_shared(implContent);
NotificationRequest req(0);
- req.SetContent(content);
req.SetLabel(NOTIFICATION_LABEL_0);
EXPECT_EQ(NotificationHelper::PublishContinuousTaskNotification(req), ERR_OK);
@@ -2518,11 +2492,7 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PulbishContinuousTask_07700, Function
IPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID);
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
-
- std::shared_ptr implContent = std::make_shared();
- std::shared_ptr content = std::make_shared(implContent);
NotificationRequest req(0);
- req.SetContent(content);
req.SetLabel(NOTIFICATION_LABEL_0);
EXPECT_EQ(NotificationHelper::PublishContinuousTaskNotification(req), ERR_OK);
SleepForFC();
@@ -2560,11 +2530,7 @@ HWTEST_F(AnsFWModuleTest, ANS_Interface_MT_PulbishContinuousTask_07800, Function
IPCSkeleton::SetCallingUid(SYSTEM_SERVICE_UID);
TestAnsSubscriber subscriber;
EXPECT_EQ(NotificationHelper::SubscribeNotification(subscriber), ERR_OK);
-
- std::shared_ptr implContent = std::make_shared();
- std::shared_ptr content = std::make_shared(implContent);
NotificationRequest req(0);
- req.SetContent(content);
req.SetLabel(NOTIFICATION_LABEL_0);
EXPECT_EQ(NotificationHelper::PublishContinuousTaskNotification(req), ERR_OK);
SleepForFC();
diff --git a/frameworks/ans/test/moduletest/mock/include/mock_bundle_manager.h b/frameworks/ans/test/moduletest/mock/include/mock_bundle_manager.h
index 3f04edd54e985e20434f983247b3b69aa334c971..ce1ef007f3d3239be5a04cfe8b1770fc8b760e9c 100644
--- a/frameworks/ans/test/moduletest/mock/include/mock_bundle_manager.h
+++ b/frameworks/ans/test/moduletest/mock/include/mock_bundle_manager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
+ * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -178,7 +178,7 @@ public:
}
/**
* @brief Query the AbilityInfo by the given Want.
- * @param want Indicates the information of the ability.
+ * @param want Indicates the infomation of the ability.
* @param abilityInfo Indicates the obtained AbilityInfo object.
* @return Returns true if the AbilityInfo is successfully obtained; returns false otherwise.
*/
@@ -449,11 +449,11 @@ public:
return true;
}
/**
- * @brief Dump the bundle information with specific flags.
+ * @brief Dump the bundle informations with specifc flags.
* @param flag Indicates the information contained in the dump result.
* @param bundleName Indicates the bundle name if needed.
* @param userId Indicates the user ID.
- * @param result Indicates the dump information result.
+ * @param result Indicates the dump infomation result.
* @return Returns true if the dump result is successfully obtained; returns false otherwise.
*/
virtual bool DumpInfos(
diff --git a/frameworks/ans/test/moduletest/mock/mock_bundle_manager_helper.cpp b/frameworks/ans/test/moduletest/mock/mock_bundle_manager_helper.cpp
deleted file mode 100644
index fdeac6723e6820bb7a97931b9baff0972d3ce38b..0000000000000000000000000000000000000000
--- a/frameworks/ans/test/moduletest/mock/mock_bundle_manager_helper.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2021 Huawei Device Co., Ltd.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "bundle_manager_helper.h"
-
-#include "if_system_ability_manager.h"
-#include "iservice_registry.h"
-#include "system_ability_definition.h"
-
-namespace OHOS {
-namespace Notification {
-BundleManagerHelper::BundleManagerHelper()
-{}
-
-BundleManagerHelper::~BundleManagerHelper()
-{}
-
-void BundleManagerHelper::OnRemoteDied(const wptr &object)
-{}
-
-std::string BundleManagerHelper::GetBundleNameByUid(int uid)
-{
- return "bundleName";
-}
-
-bool BundleManagerHelper::IsSystemApp(int uid)
-{
- return true;
-}
-
-int BundleManagerHelper::GetDefaultUidByBundleName(const std::string &bundle, const int32_t userId)
-{
- return 1000;
-}
-
-bool BundleManagerHelper::GetBundleInfoByBundleName(
- const std::string bundle, const int32_t userId, AppExecFwk::BundleInfo &bundleInfo)
-{
- return true;
-}
-
-void BundleManagerHelper::Connect()
-{}
-
-void BundleManagerHelper::Disconnect()
-{}
-} // namespace Notification
-} // namespace OHOS
\ No newline at end of file
diff --git a/interfaces/innerkits/ans/native/include/reminder_request.h b/interfaces/innerkits/ans/native/include/reminder_request.h
index 798913b6a582a95a44c45f2c865a8cb2862a4563..36c16a871a6bab767e1ec83975f6b173fb2cc6f5 100644
--- a/interfaces/innerkits/ans/native/include/reminder_request.h
+++ b/interfaces/innerkits/ans/native/include/reminder_request.h
@@ -19,11 +19,9 @@
#include