diff --git a/frameworks/ans/core/src/ans_notification.cpp b/frameworks/ans/core/src/ans_notification.cpp index fb2439edb46e917393addc84ce7b0b6eed089a26..02f3ff0d3c28e1b70585239504d67a7ffb4134ae 100644 --- a/frameworks/ans/core/src/ans_notification.cpp +++ b/frameworks/ans/core/src/ans_notification.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -1238,11 +1238,7 @@ ErrCode AnsNotification::IsSupportTemplate(const std::string &templateName, bool bool AnsNotification::IsNonDistributedNotificationType(const NotificationContent::Type &type) { - if ((type == NotificationContent::Type::CONVERSATION) || - (type == NotificationContent::Type::PICTURE)) { - return true; - } - return false; + return ((type == NotificationContent::Type::CONVERSATION) || (type == NotificationContent::Type::PICTURE)); } 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 cf6a1e51c1f0ea48e7e44258d6839b83c8e4cb0d..7afe50dcd4bab9a60f6f5c77b691ed2f200d5cca 100644 --- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css +++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.css @@ -1,3 +1,18 @@ +/* + * 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 98272a4d6462f907a61022844df7985406c2099e..73e8c517ae776509ae3d4a2cb803c5b6acb6fd52 100644 --- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml +++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.hml @@ -1,3 +1,18 @@ + +
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 928dc3b8b789e0fdcf0c8a6239d2dfde8a806ec1..202cc62bc070331ffd60566432dc5122f600cc6b 100644 --- a/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js +++ b/frameworks/ans/dialog/dialog_ui/js/pages/index/index.js @@ -1,3 +1,18 @@ +/* + * 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/src/notification_subscriber.cpp b/frameworks/ans/native/src/notification_subscriber.cpp index e3a9a3c334858baa5391f370ed84d6b87a2a8676..a0865fa929e0d5f474c1841d52efe204f2fe7852 100644 --- a/frameworks/ans/native/src/notification_subscriber.cpp +++ b/frameworks/ans/native/src/notification_subscriber.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -99,9 +99,9 @@ void NotificationSubscriber::SubscriberImpl::OnEnabledNotificationChanged( bool NotificationSubscriber::SubscriberImpl::GetAnsManagerProxy() { - if (nullptr == proxy_) { + if (proxy_ == nullptr) { std::lock_guard lock(mutex_); - if (nullptr == proxy_) { + if (proxy_ == nullptr) { 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 5adbeee6ce012ad980c68c0de62d65253e8be3f1..2c9fa188e7f98754bcb588623d01c564269113ee 100644 --- a/frameworks/ans/native/src/reminder_request.cpp +++ b/frameworks/ans/native/src/reminder_request.cpp @@ -130,7 +130,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; @@ -609,7 +609,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 { @@ -708,7 +708,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 { @@ -994,7 +994,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"); @@ -1149,7 +1149,7 @@ std::string ReminderRequest::GetShowTime(const uint64_t showTime) const std::string ReminderRequest::GetTimeInfoInner(const time_t &timeInSecond, const TimeFormat &format) const { - uint8_t dateTimeLen = 80; + const uint8_t dateTimeLen = 80; char dateTimeBuffer[dateTimeLen]; struct tm timeInfo; (void)localtime_r(&timeInSecond, &timeInfo); @@ -1365,8 +1365,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(); diff --git a/frameworks/ans/native/src/reminder_request_alarm.cpp b/frameworks/ans/native/src/reminder_request_alarm.cpp index 532202d0c16ec1303648c7cb19319e21a6164c5a..3414866e68fd7cc63325d32d8de5cd394089c941 100644 --- a/frameworks/ans/native/src/reminder_request_alarm.cpp +++ b/frameworks/ans/native/src/reminder_request_alarm.cpp @@ -50,7 +50,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)"); } diff --git a/frameworks/ans/native/src/reminder_request_calendar.cpp b/frameworks/ans/native/src/reminder_request_calendar.cpp index 746c2adcd41a1106367610d0f0c7d2e6a010a9f3..ee192aaa6940455cff6244533741f27fa098d5c9 100644 --- a/frameworks/ans/native/src/reminder_request_calendar.cpp +++ b/frameworks/ans/native/src/reminder_request_calendar.cpp @@ -86,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 = ((((0 == year % leapParam1) && (0 != year % leapParam2)) || (0 == year % solarYear)) + days = ((((year % leapParam1 == 0) && (year % leapParam2 != 0)) || (year % solarYear == 0)) ? leapMonth : nonLeapMonth); } else { days = daysArray[month - 1]; diff --git a/interfaces/kits/napi/ans/src/reminder/publish.cpp b/interfaces/kits/napi/ans/src/reminder/publish.cpp index 242a7d66c6bcac9204a23f0ef1e2683be2802444..911791e668fb299157adec66c7cbe97d12280ab4 100644 --- a/interfaces/kits/napi/ans/src/reminder/publish.cpp +++ b/interfaces/kits/napi/ans/src/reminder/publish.cpp @@ -73,7 +73,7 @@ napi_value ParseParameters(const napi_env &env, const napi_callback_info &info, size_t argc = PUBLISH_PARAM_LEN; napi_value argv[PUBLISH_PARAM_LEN] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); - if (argc < 1 || argc > PUBLISH_PARAM_LEN) { + if ((argc < 1) || (argc > PUBLISH_PARAM_LEN)) { ANSR_LOGW("Wrong number of arguments"); return nullptr; } @@ -100,7 +100,7 @@ napi_value ParseCanCelParameter(const napi_env &env, const napi_callback_info &i size_t argc = CANCEL_PARAM_LEN; napi_value argv[CANCEL_PARAM_LEN] = {nullptr}; NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, NULL, NULL)); - if (argc < 1 || argc > CANCEL_PARAM_LEN) { + if ((argc < 1) || (argc > CANCEL_PARAM_LEN)) { ANSR_LOGW("Wrong number of arguments"); return nullptr; } diff --git a/interfaces/kits/napi/ans/src/reminder/reminder_common.cpp b/interfaces/kits/napi/ans/src/reminder/reminder_common.cpp index 8ebcb860969cb471f44a1374c80839d28a30a6bf..6de7d3c6bd06aa3791156c91ddc61e3189c5f1d6 100644 --- a/interfaces/kits/napi/ans/src/reminder/reminder_common.cpp +++ b/interfaces/kits/napi/ans/src/reminder/reminder_common.cpp @@ -366,21 +366,24 @@ napi_value ReminderCommon::CreateReminderAlarm( { // hour int32_t propertyHourVal = 0; + const int32_t maxHour = 23; if (!GetInt32(env, value, ReminderAgentNapi::ALARM_HOUR, propertyHourVal, true)) { return nullptr; } // minute int32_t propertyMinuteVal = 0; + const int32_t maxMinute = 59; if (!GetInt32(env, value, ReminderAgentNapi::ALARM_MINUTE, propertyMinuteVal, true)) { return nullptr; } - if (propertyHourVal < 0 || propertyHourVal > 23) { + + if ((propertyHourVal < 0) || (propertyHourVal > maxHour)) { ANSR_LOGW("Create alarm reminder fail: designated %{public}s must between [0, 23].", ReminderAgentNapi::ALARM_HOUR); return nullptr; } - if (propertyMinuteVal < 0 || propertyMinuteVal > 59) { + if ((propertyMinuteVal < 0) || (propertyMinuteVal > maxMinute)) { ANSR_LOGW("Create alarm reminder fail: designated %{public}s must between [0, 59].", ReminderAgentNapi::ALARM_MINUTE); return nullptr; @@ -412,11 +415,11 @@ napi_value ReminderCommon::CreateReminderCalendar( int32_t propertyDayVal = 0; int32_t propertyHourVal = 0; int32_t propertyMinteVal = 0; - if (!GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_YEAR, propertyYearVal, true) - || !GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_MONTH, propertyMonthVal, true) - || !GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_DAY, propertyDayVal, true) - || !GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_HOUR, propertyHourVal, true) - || !GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_MINUTE, propertyMinteVal, true)) { + if (!GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_YEAR, propertyYearVal, true) || + !GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_MONTH, propertyMonthVal, true) || + !GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_DAY, propertyDayVal, true) || + !GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_HOUR, propertyHourVal, true) || + !GetInt32(env, dateTimeObj, ReminderAgentNapi::CALENDAR_MINUTE, propertyMinteVal, true)) { return nullptr; } if (!CheckCalendarParams(propertyYearVal, propertyMonthVal, propertyDayVal, @@ -453,18 +456,18 @@ napi_value ReminderCommon::CreateReminderCalendar( bool ReminderCommon::CheckCalendarParams(const int32_t &year, const int32_t &month, const int32_t &day, const int32_t &hour, const int32_t &min) { - if (year < 0 || year > UINT16_MAX) { + if ((year < 0) || (year > UINT16_MAX)) { ANSR_LOGW("Create calendar reminder fail: designated %{public}s must between [0, %{public}d]", ReminderAgentNapi::CALENDAR_YEAR, UINT16_MAX); return false; } - if (month < 1 || month > ReminderRequestCalendar::MAX_MONTHS_OF_YEAR) { + if ((month < 1 || month) > (ReminderRequestCalendar::MAX_MONTHS_OF_YEAR)) { ANSR_LOGW("Create calendar reminder fail: designated %{public}s must between [1, %{public}hhu]", ReminderAgentNapi::CALENDAR_MONTH, ReminderRequestCalendar::MAX_MONTHS_OF_YEAR); return false; } uint8_t maxDaysOfMonth = ReminderRequestCalendar::GetDaysOfMonth(static_cast(year), month); - if (day < 1 || day > maxDaysOfMonth) { + if ((day < 1) || (day > maxDaysOfMonth)) { ANSR_LOGW("Create calendar reminder fail: designated %{public}s must between [1, %{public}hhu]", ReminderAgentNapi::CALENDAR_DAY, maxDaysOfMonth); return false; diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index 89bb2b22c252b678f6285ba562f46db8324da47e..dd8493b0306a64c5ba5ab43af04ee9e3145dee8f 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -1362,7 +1362,7 @@ void NotificationPreferencesDatabase::GetDoNotDisturbType(NotificationPreference } } } else { - ANS_LOGW("Parse disturbe mode failed, use defalut value."); + ANS_LOGW("Parse disturbe mode failed, use default value."); } info.SetDoNotDisturbDate(userId, disturbDate); }); @@ -1386,7 +1386,7 @@ void NotificationPreferencesDatabase::GetDoNotDisturbBeginDate(NotificationPrefe } } } else { - ANS_LOGW("Parse disturbe start time failed, use defalut value."); + ANS_LOGW("Parse disturbe start time failed, use default value."); } info.SetDoNotDisturbDate(userId, disturbDate); }); @@ -1410,7 +1410,7 @@ void NotificationPreferencesDatabase::GetDoNotDisturbEndDate(NotificationPrefere } } } else { - ANS_LOGW("Parse disturbe end time failed, use defalut value."); + ANS_LOGW("Parse disturbe end time failed, use default value."); } info.SetDoNotDisturbDate(userId, disturbDate); }); @@ -1434,7 +1434,7 @@ void NotificationPreferencesDatabase::GetEnableAllNotification(NotificationPrefe info.SetEnabledAllNotification(userId, static_cast(StringToInt(value.ToString()))); } } else { - ANS_LOGW("Parse enable all notification failed, use defalut value."); + ANS_LOGW("Parse enable all notification failed, use default value."); } }); } diff --git a/services/ans/src/notification_preferences_info.cpp b/services/ans/src/notification_preferences_info.cpp index 1afe46b42ffd44781c82a602940a94cc3bf6d02e..145118acd74c9c86cf96effa29a10b2ae7e6139d 100644 --- a/services/ans/src/notification_preferences_info.cpp +++ b/services/ans/src/notification_preferences_info.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 diff --git a/services/ans/src/notification_subscriber_manager.cpp b/services/ans/src/notification_subscriber_manager.cpp index cb9342f9ee7715a5bd20f05cb1363a5c414facfc..6b275d9cd090d338a6e483c4290ce5d4339119ad 100644 --- a/services/ans/src/notification_subscriber_manager.cpp +++ b/services/ans/src/notification_subscriber_manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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 @@ -360,11 +360,7 @@ void NotificationSubscriberManager::NotifyDoNotDisturbDateChangedInner(const spt bool NotificationSubscriberManager::IsSystemUser(int32_t userId) { - if (userId >= SUBSCRIBE_USER_SYSTEM_BEGIN && userId <= SUBSCRIBE_USER_SYSTEM_END) { - return true; - } - - return false; + return ((userId >= SUBSCRIBE_USER_SYSTEM_BEGIN) && (userId <= SUBSCRIBE_USER_SYSTEM_END)); } void NotificationSubscriberManager::NotifyEnabledNotificationChangedInner( diff --git a/services/test/moduletest/mock/include/mock_single_kv_store.h b/services/test/moduletest/mock/include/mock_single_kv_store.h index b682e43151bbd0c60c21ec51decf5460a8b8ee01..bea39c9cf98070da721c49c234bc69328c1a0f0c 100644 --- a/services/test/moduletest/mock/include/mock_single_kv_store.h +++ b/services/test/moduletest/mock/include/mock_single_kv_store.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * 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