From 68315c45ed35cb4e860c675a7bbd38fb0a5e6eec Mon Sep 17 00:00:00 2001 From: fangJinliang1 Date: Thu, 18 May 2023 12:40:15 +0800 Subject: [PATCH] fixed 6791dce from https://gitee.com/fangJinliang1/notification_ans_standard/pulls/1017 fix bug Signed-off-by: fangJinliang1 Change-Id: I2a05e0eeac34897b65a462250f427bcf94d7965e Signed-off-by: fangJinliang1 --- .../core/include/ans_manager_interface.h | 18 -- frameworks/core/include/ans_manager_proxy.h | 16 -- frameworks/core/include/ans_manager_stub.h | 18 -- frameworks/core/src/ans_manager_proxy.cpp | 58 ------ frameworks/core/src/ans_manager_stub.cpp | 45 ---- .../ans_manager_proxy_unit_test.cpp | 194 ------------------ .../ans_manager_stub_test.cpp | 64 ------ .../include/advanced_notification_service.h | 16 -- .../ans/include/notification_preferences.h | 18 -- .../notification_preferences_database.h | 11 - .../include/notification_preferences_info.h | 15 -- services/ans/include/preferences_constant.h | 6 - .../ans/src/advanced_notification_service.cpp | 40 +--- services/ans/src/notification_preferences.cpp | 30 --- .../src/notification_preferences_database.cpp | 41 ---- .../ans/src/notification_preferences_info.cpp | 10 - .../advanced_notification_service_test.cpp | 52 ----- ...ation_preferences_database_branch_test.cpp | 36 ---- ...notification_preferences_database_test.cpp | 42 ---- .../notification_preferences_test.cpp | 76 ------- .../notification_service_test.cpp | 38 ---- .../ansmanagerstub_fuzzer.cpp | 4 - .../ansmanagerstubannexthree_fuzzer.cpp | 1 - .../ansmanagerstubannextwo_fuzzer.cpp | 2 +- 24 files changed, 5 insertions(+), 846 deletions(-) diff --git a/frameworks/core/include/ans_manager_interface.h b/frameworks/core/include/ans_manager_interface.h index 47cd1a4dc..342082b15 100644 --- a/frameworks/core/include/ans_manager_interface.h +++ b/frameworks/core/include/ans_manager_interface.h @@ -246,22 +246,6 @@ public: */ virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) = 0; - /** - * @brief Set whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetPrivateNotificationsAllowed(bool allow) = 0; - - /** - * @brief Get whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetPrivateNotificationsAllowed(bool &allow) = 0; - /** * @brief Delete notification based on key. * @@ -716,8 +700,6 @@ protected: SET_NOTIFICATION_BADGE_NUM, GET_BUNDLE_IMPORTANCE, IS_NOTIFICATION_POLICY_ACCESS_GRANTED, - SET_PRIVATIVE_NOTIFICATIONS_ALLOWED, - GET_PRIVATIVE_NOTIFICATIONS_ALLOWED, REMOVE_NOTIFICATION, REMOVE_ALL_NOTIFICATIONS, DELETE_NOTIFICATION, diff --git a/frameworks/core/include/ans_manager_proxy.h b/frameworks/core/include/ans_manager_proxy.h index 0ff6cc564..2010a412c 100644 --- a/frameworks/core/include/ans_manager_proxy.h +++ b/frameworks/core/include/ans_manager_proxy.h @@ -234,22 +234,6 @@ public: */ ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; - /** - * @brief Set whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetPrivateNotificationsAllowed(bool allow) override; - - /** - * @brief Get whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetPrivateNotificationsAllowed(bool &allow) override; - /** * @brief Delete notification. * diff --git a/frameworks/core/include/ans_manager_stub.h b/frameworks/core/include/ans_manager_stub.h index 4f8f54245..d4f4cc190 100644 --- a/frameworks/core/include/ans_manager_stub.h +++ b/frameworks/core/include/ans_manager_stub.h @@ -249,22 +249,6 @@ public: */ virtual ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; - /** - * @brief Set whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode SetPrivateNotificationsAllowed(bool allow) override; - - /** - * @brief Get whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - virtual ErrCode GetPrivateNotificationsAllowed(bool &allow) override; - /** * @brief Delete notification. * @@ -722,8 +706,6 @@ private: ErrCode HandleSetNotificationBadgeNum(MessageParcel &data, MessageParcel &reply); ErrCode HandleGetBundleImportance(MessageParcel &data, MessageParcel &reply); ErrCode HandleIsNotificationPolicyAccessGranted(MessageParcel &data, MessageParcel &reply); - ErrCode HandleSetPrivateNotificationsAllowed(MessageParcel &data, MessageParcel &reply); - ErrCode HandleGetPrivateNotificationsAllowed(MessageParcel &data, MessageParcel &reply); ErrCode HandleRemoveNotification(MessageParcel &data, MessageParcel &reply); ErrCode HandleRemoveAllNotifications(MessageParcel &data, MessageParcel &reply); ErrCode HandleDelete(MessageParcel &data, MessageParcel &reply); diff --git a/frameworks/core/src/ans_manager_proxy.cpp b/frameworks/core/src/ans_manager_proxy.cpp index f06d8af4e..fc607eb36 100644 --- a/frameworks/core/src/ans_manager_proxy.cpp +++ b/frameworks/core/src/ans_manager_proxy.cpp @@ -738,64 +738,6 @@ ErrCode AnsManagerProxy::HasNotificationPolicyAccessPermission(bool &granted) return result; } -ErrCode AnsManagerProxy::SetPrivateNotificationsAllowed(bool allow) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[SetPrivateNotificationsAllowed] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!data.WriteBool(allow)) { - ANS_LOGE("[SetPrivateNotificationsAllowed] fail: write allow failed"); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(SET_PRIVATIVE_NOTIFICATIONS_ALLOWED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[SetPrivateNotificationsAllowed] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[SetPrivateNotificationsAllowed] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - -ErrCode AnsManagerProxy::GetPrivateNotificationsAllowed(bool &allow) -{ - MessageParcel data; - if (!data.WriteInterfaceToken(AnsManagerProxy::GetDescriptor())) { - ANS_LOGE("[GetPrivateNotificationsAllowed] fail: write interface token failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - ErrCode result = InnerTransact(GET_PRIVATIVE_NOTIFICATIONS_ALLOWED, option, data, reply); - if (result != ERR_OK) { - ANS_LOGE("[GetPrivateNotificationsAllowed] fail: transact ErrCode=%{public}d", result); - return ERR_ANS_TRANSACT_FAILED; - } - - if (!reply.ReadInt32(result)) { - ANS_LOGE("[GetPrivateNotificationsAllowed] fail: read result failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - if (!reply.ReadBool(allow)) { - ANS_LOGE("[GetPrivateNotificationsAllowed] fail: read allow failed."); - return ERR_ANS_PARCELABLE_FAILED; - } - - return result; -} - ErrCode AnsManagerProxy::RemoveNotification(const sptr &bundleOption, int32_t notificationId, const std::string &label, int32_t removeReason) { diff --git a/frameworks/core/src/ans_manager_stub.cpp b/frameworks/core/src/ans_manager_stub.cpp index 631cfdd9f..495364610 100644 --- a/frameworks/core/src/ans_manager_stub.cpp +++ b/frameworks/core/src/ans_manager_stub.cpp @@ -94,12 +94,6 @@ const std::map bundleOption = data.ReadStrongParcelable(); @@ -1919,18 +1886,6 @@ ErrCode AnsManagerStub::HasNotificationPolicyAccessPermission(bool &granted) return ERR_INVALID_OPERATION; } -ErrCode AnsManagerStub::SetPrivateNotificationsAllowed(bool allow) -{ - ANS_LOGE("AnsManagerStub::SetPrivateNotificationsAllowed called!"); - return ERR_INVALID_OPERATION; -} - -ErrCode AnsManagerStub::GetPrivateNotificationsAllowed(bool &allow) -{ - ANS_LOGE("AnsManagerStub::GetPrivateNotificationsAllowed called!"); - return ERR_INVALID_OPERATION; -} - ErrCode AnsManagerStub::RemoveNotification(const sptr &bundleOption, int notificationId, const std::string &label, int32_t removeReason) { diff --git a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp index 0a5923d3b..3d8a37490 100644 --- a/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_proxy_test/ans_manager_proxy_unit_test.cpp @@ -2763,200 +2763,6 @@ HWTEST_F(AnsManagerProxyUnitTest, HasNotificationPolicyAccessPermissionTest_0500 EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); } -/* - * @tc.name: SetPrivateNotificationsAllowedTest_0100 - * @tc.desc: test SetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetPrivateNotificationsAllowedTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetPrivateNotificationsAllowedTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = true; - int32_t result = proxy->SetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: SetPrivateNotificationsAllowedTest_0200 - * @tc.desc: test SetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetPrivateNotificationsAllowedTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetPrivateNotificationsAllowedTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = true; - int32_t result = proxy->SetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_OK, result); -} -/* - * @tc.name: SetPrivateNotificationsAllowedTest_0300 - * @tc.desc: test SetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetPrivateNotificationsAllowedTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetPrivateNotificationsAllowedTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = true; - int32_t result = proxy->SetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: SetPrivateNotificationsAllowedTest_0400 - * @tc.desc: test SetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, SetPrivateNotificationsAllowedTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, SetPrivateNotificationsAllowedTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, false, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = true; - int32_t result = proxy->SetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetPrivateNotificationsAllowedTest_0100 - * @tc.desc: test GetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0100, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0100, TestSize.Level1"; - MockWriteInterfaceToken(false); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = false; - int32_t result = proxy->GetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetPrivateNotificationsAllowedTest_0200 - * @tc.desc: test GetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0200, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0200, TestSize.Level1"; - MockWriteInterfaceToken(true); - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = false; - int32_t result = proxy->GetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_OK, result); - EXPECT_EQ(true, allow); -} - -/* - * @tc.name: GetPrivateNotificationsAllowedTest_0300 - * @tc.desc: test GetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0300, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0300, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Return(DEAD_OBJECT))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = false; - int32_t result = proxy->GetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_ANS_TRANSACT_FAILED, result); -} - -/* - * @tc.name: GetPrivateNotificationsAllowedTest_0400 - * @tc.desc: test GetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0400, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0400, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, false, true, true)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = false; - int32_t result = proxy->GetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - -/* - * @tc.name: GetPrivateNotificationsAllowedTest_0500 - * @tc.desc: test GetPrivateNotificationsAllowed function - * @tc.type: FUNC - * @tc.require: #I5XO2O - */ -HWTEST_F(AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0500, Function | MediumTest | Level1) -{ - GTEST_LOG_(INFO) - << "AnsManagerProxyUnitTest, GetPrivateNotificationsAllowedTest_0500, TestSize.Level1"; - sptr iremoteObject = new (std::nothrow) MockIRemoteObject(); - ASSERT_NE(nullptr, iremoteObject); - EXPECT_CALL(*iremoteObject, SendRequest(_, _, _, _)).Times(1) - .WillRepeatedly(DoAll(Invoke(std::bind(SendRequestReplace, _1, _2, _3, _4, - ERR_OK, true, true, false)), Return(NO_ERROR))); - std::shared_ptr proxy = std::make_shared(iremoteObject); - ASSERT_NE(nullptr, proxy); - bool allow = false; - int32_t result = proxy->GetPrivateNotificationsAllowed(allow); - EXPECT_EQ(ERR_ANS_PARCELABLE_FAILED, result); -} - /* * @tc.name: RemoveNotificationTest_0100 * @tc.desc: test RemoveNotification function diff --git a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp index d3a867d9d..ea63a1172 100644 --- a/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp +++ b/frameworks/core/test/unittest/ans_manager_stub_test/ans_manager_stub_test.cpp @@ -938,44 +938,6 @@ HWTEST_F(AnsManagerStubTest, HandleIsNotificationPolicyAccessGranted01, Function EXPECT_EQ(ret, (int)NO_ERROR); } -/** - * @tc.name: HandleSetPrivateNotificationsAllowed02 - * @tc.desc: Test if the allow in data is null. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleSetPrivateNotificationsAllowed02, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::SET_PRIVATIVE_NOTIFICATIONS_ALLOWED); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)ERR_ANS_PARCELABLE_FAILED); -} - -/** - * @tc.name: HandleGetPrivateNotificationsAllowed01 - * @tc.desc: Test HandleGetPrivateNotificationsAllowed succeed. - * @tc.type: FUNC - * @tc.require: issueI5XQ4E - */ -HWTEST_F(AnsManagerStubTest, HandleGetPrivateNotificationsAllowed01, Function | SmallTest | Level1) -{ - uint32_t code = static_cast(AnsManagerInterface::TransactId::GET_PRIVATIVE_NOTIFICATIONS_ALLOWED); - MessageParcel data; - MessageParcel reply; - MessageOption option = {MessageOption::TF_SYNC}; - - data.WriteInterfaceToken(AnsManagerStub::GetDescriptor()); - - ErrCode ret = ansManagerStub_->OnRemoteRequest(code, data, reply, option); - EXPECT_EQ(ret, (int)NO_ERROR); -} - /** * @tc.name: HandleRemoveNotification01 * @tc.desc: Test HandleRemoveNotification succeed. @@ -3543,32 +3505,6 @@ HWTEST_F(AnsManagerStubTest, HasNotificationPolicyAccessPermission01, Function | EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); } -/** - * @tc.name: SetPrivateNotificationsAllowed01 - * @tc.desc: Test SetPrivateNotificationsAllowed return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, SetPrivateNotificationsAllowed01, Function | SmallTest | Level1) -{ - bool allow = true; - ErrCode result = ansManagerStub_->SetPrivateNotificationsAllowed(allow); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - -/** - * @tc.name: GetPrivateNotificationsAllowed01 - * @tc.desc: Test GetPrivateNotificationsAllowed return. - * @tc.type: FUNC - * @tc.require: issueI620XB - */ -HWTEST_F(AnsManagerStubTest, GetPrivateNotificationsAllowed01, Function | SmallTest | Level1) -{ - bool allow = true; - ErrCode result = ansManagerStub_->GetPrivateNotificationsAllowed(allow); - EXPECT_EQ(result, (int)ERR_INVALID_OPERATION); -} - /** * @tc.name: RemoveNotification01 * @tc.desc: Test RemoveNotification return. diff --git a/services/ans/include/advanced_notification_service.h b/services/ans/include/advanced_notification_service.h index 5b3e0fde3..45ee701ef 100644 --- a/services/ans/include/advanced_notification_service.h +++ b/services/ans/include/advanced_notification_service.h @@ -260,22 +260,6 @@ public: */ ErrCode HasNotificationPolicyAccessPermission(bool &granted) override; - /** - * @brief Set whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode SetPrivateNotificationsAllowed(bool allow) override; - - /** - * @brief Get whether to allow private notifications. - * - * @param allow Indicates the flag that allows private notification. - * @return Returns ERR_OK on success, others on failure. - */ - ErrCode GetPrivateNotificationsAllowed(bool &allow) override; - /** * @brief Delete notification. * diff --git a/services/ans/include/notification_preferences.h b/services/ans/include/notification_preferences.h index da1f339f1..15484ecaf 100644 --- a/services/ans/include/notification_preferences.h +++ b/services/ans/include/notification_preferences.h @@ -173,24 +173,6 @@ public: */ ErrCode SetTotalBadgeNums(const sptr &bundleOption, const int32_t num); - /** - * @brief Get private notification allowed in the of bunlde from DB. - * - * @param bundleOption Indicates bunlde info label. - * @param allow Indicates to whether to allow. - * @return Return ERR_OK on success, others on failure. - */ - ErrCode GetPrivateNotificationsAllowed(const sptr &bundleOption, bool &allow); - - /** - * @brief Set private notification allowed in the of bunlde from DB. - * - * @param bundleOption Indicates bunlde info label. - * @param allow Indicates to set allow. - * @return Return ERR_OK on success, others on failure. - */ - ErrCode SetPrivateNotificationsAllowed(const sptr &bundleOption, const bool allow); - /** * @brief Get private notification enable in the of bunlde from DB. * diff --git a/services/ans/include/notification_preferences_database.h b/services/ans/include/notification_preferences_database.h index c4fbc3903..afc046043 100644 --- a/services/ans/include/notification_preferences_database.h +++ b/services/ans/include/notification_preferences_database.h @@ -77,15 +77,6 @@ public: */ bool PutTotalBadgeNums(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const int32_t &totalBadgeNum); - /** - * @brief Put private notification allowed in the of bundle into disturbe DB. - * - * @param bundleInfo Indicates bundle info. - * @param allow Indicates to whether to allow - * @return Return true on success, false on failure. - */ - bool PutPrivateNotificationsAllowed(const NotificationPreferencesInfo::BundleInfo &bundleInfo, const bool &allow); - /** * @brief Put enable notification in the of bundle into disturbe DB. * @@ -213,8 +204,6 @@ private: void ParseBundleImportance(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; void ParseBundleShowBadge(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; void ParseBundleBadgeNum(NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; - void ParseBundlePrivateAllowed( - NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; void ParseBundleEnableNotification( NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const; void ParseBundlePoppedDialog( diff --git a/services/ans/include/notification_preferences_info.h b/services/ans/include/notification_preferences_info.h index 895c80478..6e1272d6e 100644 --- a/services/ans/include/notification_preferences_info.h +++ b/services/ans/include/notification_preferences_info.h @@ -89,20 +89,6 @@ public: */ int32_t GetBadgeTotalNum() const; - /** - * @brief Set bundle Whether to private allowed. - * - * @param name Indicates the set Whether to private allowed. - */ - void SetIsPrivateAllowed(const bool &isPrivateAllowed); - - /** - * @brief Get bundle Whether to private allowed. - * - * @return Return true on success, false on failure. - */ - bool GetIsPrivateAllowed() const; - /** * @brief Set bundle enable notification. * @@ -203,7 +189,6 @@ public: int32_t importance_ = BUNDLE_IMPORTANCE; bool isShowBadge_ = BUNDLE_SHOW_BADGE; int32_t badgeTotalNum_ = BUNDLE_BADGE_TOTAL_NUM; - bool isPrivateAllowed_ = BUNDLE_PRIVATE_ALLOWED; bool isEnabledNotification_ = BUNDLE_ENABLE_NOTIFICATION; bool hasPoppedDialog_ = BUNDLE_POPPED_DIALOG; std::map> slots_; diff --git a/services/ans/include/preferences_constant.h b/services/ans/include/preferences_constant.h index fae1fd77e..034cc65d5 100644 --- a/services/ans/include/preferences_constant.h +++ b/services/ans/include/preferences_constant.h @@ -38,11 +38,6 @@ const static int BUNDLE_IMPORTANCE = 3; */ const static int BUNDLE_BADGE_TOTAL_NUM = 0; -/** - * Default params that bundle private allowed is false. - */ -const static int BUNDLE_PRIVATE_ALLOWED = false; - /** * Default params that bundle enable notification is true. */ @@ -62,7 +57,6 @@ enum class BundleType { BUNDLE_IMPORTANCE_TYPE, BUNDLE_SHOW_BADGE_TYPE, BUNDLE_BADGE_TOTAL_NUM_TYPE, - BUNDLE_PRIVATE_ALLOWED_TYPE, BUNDLE_ENABLE_NOTIFICATION_TYPE, BUNDLE_POPPED_DIALOG_TYPE, }; diff --git a/services/ans/src/advanced_notification_service.cpp b/services/ans/src/advanced_notification_service.cpp index 0272ff621..29c3ac1dc 100644 --- a/services/ans/src/advanced_notification_service.cpp +++ b/services/ans/src/advanced_notification_service.cpp @@ -220,6 +220,10 @@ ErrCode AdvancedNotificationService::PrepareNotificationRequest(const sptrIsAgentNotification()) { bool isSubsystem = AccessTokenHelper::VerifyNativeToken(IPCSkeleton::GetCallingTokenID()); @@ -879,42 +883,6 @@ ErrCode AdvancedNotificationService::HasNotificationPolicyAccessPermission(bool return ERR_OK; } -ErrCode AdvancedNotificationService::SetPrivateNotificationsAllowed(bool allow) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - - sptr bundleOption = GenerateBundleOption(); - if (bundleOption == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - - ErrCode result = ERR_OK; - handler_->PostSyncTask(std::bind([&]() { - result = NotificationPreferences::GetInstance().SetPrivateNotificationsAllowed(bundleOption, allow); - })); - return result; -} - -ErrCode AdvancedNotificationService::GetPrivateNotificationsAllowed(bool &allow) -{ - ANS_LOGD("%{public}s", __FUNCTION__); - - sptr bundleOption = GenerateBundleOption(); - if (bundleOption == nullptr) { - return ERR_ANS_INVALID_BUNDLE; - } - - ErrCode result = ERR_OK; - handler_->PostSyncTask(std::bind([&]() { - result = NotificationPreferences::GetInstance().GetPrivateNotificationsAllowed(bundleOption, allow); - if (result == ERR_ANS_PREFERENCES_NOTIFICATION_BUNDLE_NOT_EXIST) { - result = ERR_OK; - allow = false; - } - })); - return result; -} - ErrCode AdvancedNotificationService::Delete(const std::string &key, int32_t removeReason) { ANS_LOGD("%{public}s", __FUNCTION__); diff --git a/services/ans/src/notification_preferences.cpp b/services/ans/src/notification_preferences.cpp index 19e7daaa0..16ee92cc7 100644 --- a/services/ans/src/notification_preferences.cpp +++ b/services/ans/src/notification_preferences.cpp @@ -314,29 +314,6 @@ ErrCode NotificationPreferences::SetTotalBadgeNums( return result; } -ErrCode NotificationPreferences::GetPrivateNotificationsAllowed( - const sptr &bundleOption, bool &allow) -{ - if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { - return ERR_ANS_INVALID_PARAM; - } - return GetBundleProperty(bundleOption, BundleType::BUNDLE_PRIVATE_ALLOWED_TYPE, allow); -} - -ErrCode NotificationPreferences::SetPrivateNotificationsAllowed( - const sptr &bundleOption, const bool allow) -{ - if (bundleOption == nullptr || bundleOption->GetBundleName().empty()) { - return ERR_ANS_INVALID_PARAM; - } - NotificationPreferencesInfo preferencesInfo = preferencesInfo_; - ErrCode result = SetBundleProperty(preferencesInfo, bundleOption, BundleType::BUNDLE_PRIVATE_ALLOWED_TYPE, allow); - if (result == ERR_OK) { - preferencesInfo_ = preferencesInfo; - } - return result; -} - ErrCode NotificationPreferences::GetNotificationsEnabledForBundle( const sptr &bundleOption, bool &enabled) { @@ -572,10 +549,6 @@ ErrCode NotificationPreferences::SaveBundleProperty(NotificationPreferencesInfo: bundleInfo.SetIsShowBadge(value); storeDBResult = preferncesDB_->PutShowBadge(bundleInfo, value); break; - case BundleType::BUNDLE_PRIVATE_ALLOWED_TYPE: - bundleInfo.SetIsPrivateAllowed(value); - storeDBResult = preferncesDB_->PutPrivateNotificationsAllowed(bundleInfo, value); - break; case BundleType::BUNDLE_ENABLE_NOTIFICATION_TYPE: bundleInfo.SetEnableNotification(value); storeDBResult = preferncesDB_->PutNotificationsEnabledForBundle(bundleInfo, value); @@ -607,9 +580,6 @@ ErrCode NotificationPreferences::GetBundleProperty( case BundleType::BUNDLE_SHOW_BADGE_TYPE: value = bundleInfo.GetIsShowBadge(); break; - case BundleType::BUNDLE_PRIVATE_ALLOWED_TYPE: - value = bundleInfo.GetIsPrivateAllowed(); - break; case BundleType::BUNDLE_ENABLE_NOTIFICATION_TYPE: value = bundleInfo.GetEnableNotification(); break; diff --git a/services/ans/src/notification_preferences_database.cpp b/services/ans/src/notification_preferences_database.cpp index ce85d2d25..2eeaa68f7 100644 --- a/services/ans/src/notification_preferences_database.cpp +++ b/services/ans/src/notification_preferences_database.cpp @@ -78,11 +78,6 @@ const static std::string KEY_BUNDLE_SHOW_BADGE = "showBadge"; */ const static std::string KEY_BUNDLE_BADGE_TOTAL_NUM = "badgeTotalNum"; -/** - * Indicates that disturbe key which bundle private allowed. - */ -const static std::string KEY_BUNDLE_PRIVATE_ALLOWED = "privateAllowed"; - /** * Indicates that disturbe key which bundle enable notification. */ @@ -257,11 +252,6 @@ const std::map(StringToInt(value))); -} - void NotificationPreferencesDatabase::ParseBundleEnableNotification( NotificationPreferencesInfo::BundleInfo &bundleInfo, const std::string &value) const { diff --git a/services/ans/src/notification_preferences_info.cpp b/services/ans/src/notification_preferences_info.cpp index b0cb322b4..bc28ad929 100644 --- a/services/ans/src/notification_preferences_info.cpp +++ b/services/ans/src/notification_preferences_info.cpp @@ -61,16 +61,6 @@ int32_t NotificationPreferencesInfo::BundleInfo::GetBadgeTotalNum() const return badgeTotalNum_; } -void NotificationPreferencesInfo::BundleInfo::SetIsPrivateAllowed(const bool &isPrivateAllowed) -{ - isPrivateAllowed_ = isPrivateAllowed; -} - -bool NotificationPreferencesInfo::BundleInfo::GetIsPrivateAllowed() const -{ - return isPrivateAllowed_; -} - void NotificationPreferencesInfo::BundleInfo::SetEnableNotification(const bool &enable) { isEnabledNotification_ = enable; diff --git a/services/ans/test/unittest/advanced_notification_service_test.cpp b/services/ans/test/unittest/advanced_notification_service_test.cpp index 0c44df22a..6ae54b83b 100644 --- a/services/ans/test/unittest/advanced_notification_service_test.cpp +++ b/services/ans/test/unittest/advanced_notification_service_test.cpp @@ -503,31 +503,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_01900, EXPECT_EQ((int)advancedNotificationService_->GetBundleImportance(importance), (int)ERR_OK); } -/** - * @tc.number : AdvancedNotificationServiceTest_02000 - * @tc.name : ANS_SetPrivateNotificationsAllowed_0100 - * @tc.desc : Test SetPrivateNotificationsAllowed function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02000, Function | SmallTest | Level1) -{ - TestAddSlot(NotificationConstant::SlotType::OTHER); - EXPECT_EQ((int)advancedNotificationService_->SetPrivateNotificationsAllowed(true), (int)ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationServiceTest_02100 - * @tc.name : ANS_GetPrivateNotificationsAllowed_0100 - * @tc.desc : Test GetPrivateNotificationsAllowed function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_02100, Function | SmallTest | Level1) -{ - TestAddSlot(NotificationConstant::SlotType::OTHER); - EXPECT_EQ((int)advancedNotificationService_->SetPrivateNotificationsAllowed(true), (int)ERR_OK); - bool allow = false; - EXPECT_EQ((int)advancedNotificationService_->GetPrivateNotificationsAllowed(allow), (int)ERR_OK); - EXPECT_TRUE(allow); -} - /** * @tc.number : AdvancedNotificationServiceTest_02200 * @tc.name : ANS_UpdateSlots_0100 @@ -852,31 +827,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06000, EXPECT_EQ((int)advancedNotificationService_->GetBundleImportance(importance), (int)ERR_OK); } -/** - * @tc.number : AdvancedNotificationServiceTest_06100 - * @tc.name : ANS_SetPrivateNotificationsAllowed_0100 - * @tc.desc : Test SetPrivateNotificationsAllowed function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06100, Function | SmallTest | Level1) -{ - TestAddSlot(NotificationConstant::SlotType::OTHER); - EXPECT_EQ((int)advancedNotificationService_->SetPrivateNotificationsAllowed(true), (int)ERR_OK); -} - -/** - * @tc.number : AdvancedNotificationServiceTest_06200 - * @tc.name : ANS_GetPrivateNotificationsAllowed_0100 - * @tc.desc : Test GetPrivateNotificationsAllowed function - */ -HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_06200, Function | SmallTest | Level1) -{ - TestAddSlot(NotificationConstant::SlotType::OTHER); - EXPECT_EQ((int)advancedNotificationService_->SetPrivateNotificationsAllowed(true), (int)ERR_OK); - bool allow = false; - EXPECT_EQ((int)advancedNotificationService_->GetPrivateNotificationsAllowed(allow), (int)ERR_OK); - EXPECT_TRUE(allow); -} - /** * @tc.number : AdvancedNotificationServiceTest_06300 * @tc.name : ANS_UpdateSlots_0100 @@ -2363,8 +2313,6 @@ HWTEST_F(AdvancedNotificationServiceTest, AdvancedNotificationServiceTest_16900, int32_t importance = 2; EXPECT_EQ(advancedNotificationService_->GetBundleImportance(importance), ERR_ANS_INVALID_BUNDLE); bool allow = true; - EXPECT_EQ(advancedNotificationService_->SetPrivateNotificationsAllowed(allow), ERR_ANS_INVALID_BUNDLE); - EXPECT_EQ(advancedNotificationService_->GetPrivateNotificationsAllowed(allow), ERR_ANS_INVALID_BUNDLE); EXPECT_EQ(advancedNotificationService_->GetShowBadgeEnabled(allow), ERR_ANS_INVALID_BUNDLE); sptr slot = new NotificationSlot(NotificationConstant::OTHER); diff --git a/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp b/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp index d89bf439e..73126ebcd 100755 --- a/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_branch_test/notification_preferences_database_branch_test.cpp @@ -175,26 +175,6 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0070 EXPECT_EQ(preferncesDB_->PutTotalBadgeNums(bundleInfo, totalBadgeNum), false); } -/** - * @tc.name : NotificationPreferences_00800 - * @tc.number : - * @tc.desc : test PutPrivateNotificationsAllowed function and CheckBundle is false - */ -HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_00800, Function | SmallTest | Level1) -{ - // set GetBundleName is not empty - NotificationPreferencesInfo::BundleInfo bundleInfo; - std::string name = ""; - bundleInfo.SetBundleName(name); - // set CheckRdbStore is true - MockInit(true); - // set status is NativeRdb::E_ERROR - MockQueryData(true); - // test PutPrivateNotificationsAllowed function - bool allow = true; - EXPECT_EQ(preferncesDB_->PutPrivateNotificationsAllowed(bundleInfo, allow), false); -} - /** * @tc.name : NotificationPreferences_00900 * @tc.number : @@ -595,22 +575,6 @@ HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_0330 EXPECT_EQ(preferncesDB_->PutBundlePropertyToDisturbeDB(bundleKey, type, true), false); } -/** - * @tc.name : NotificationPreferences_03400 - * @tc.number : - * @tc.desc : test PutBundlePropertyToDisturbeDB function and type is BUNDLE_PRIVATE_ALLOWED_TYPE - */ -HWTEST_F(NotificationPreferencesDatabaseBranchTest, NotificationPreferences_03400, Function | SmallTest | Level1) -{ - // set CheckRdbStore is false - MockInit(false); - // set type is BUNDLE_PRIVATE_ALLOWED_TYPE - BundleType type = BundleType::BUNDLE_PRIVATE_ALLOWED_TYPE; - // test PutBundlePropertyToDisturbeDB function - std::string bundleKey = ""; - EXPECT_EQ(preferncesDB_->PutBundlePropertyToDisturbeDB(bundleKey, type, true), false); -} - /** * @tc.name : NotificationPreferences_03500 * @tc.number : diff --git a/services/ans/test/unittest/notification_preferences_database_test.cpp b/services/ans/test/unittest/notification_preferences_database_test.cpp index 38decf77f..a9756c5b6 100644 --- a/services/ans/test/unittest/notification_preferences_database_test.cpp +++ b/services/ans/test/unittest/notification_preferences_database_test.cpp @@ -172,33 +172,6 @@ HWTEST_F(NotificationPreferencesDatabaseTest, PutTotalBadgeNums_00200, Function EXPECT_FALSE(preferncesDB_->PutTotalBadgeNums(bundleInfo, 0)); } -/** - * @tc.name : PutPrivateNotificationsAllowed_00100 - * @tc.number : - * @tc.desc : Put bundle private notification allowed into disturbe DB, return is true. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, PutPrivateNotificationsAllowed_00100, Function | SmallTest | Level1) -{ - NotificationPreferencesInfo::BundleInfo bundleInfo; - bundleInfo.SetBundleName(bundleName_); - bundleInfo.SetBundleUid(bundleUid_); - EXPECT_TRUE(preferncesDB_->PutPrivateNotificationsAllowed(bundleInfo, true)); - EXPECT_TRUE(preferncesDB_->PutPrivateNotificationsAllowed(bundleInfo, true)); -} - -/** - * @tc.name : PutPrivateNotificationsAllowed_00200 - * @tc.number : - * @tc.desc : Put bundle private notification allowed into disturbe DB when bundle name is null, return is false. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, PutPrivateNotificationsAllowed_00200, Function | SmallTest | Level1) -{ - NotificationPreferencesInfo::BundleInfo bundleInfo; - bundleInfo.SetBundleName(std::string()); - bundleInfo.SetBundleUid(bundleUid_); - EXPECT_FALSE(preferncesDB_->PutPrivateNotificationsAllowed(bundleInfo, false)); -} - /** * @tc.name : PutNotificationsEnabledForBundle_00100 * @tc.number : @@ -305,21 +278,6 @@ HWTEST_F(NotificationPreferencesDatabaseTest, PutDoNotDisturbDate_00400, Functio EXPECT_TRUE(preferncesDB_->PutDoNotDisturbDate(userId, date)); } -/** - * @tc.number : ParseFromDisturbeDB_00100 - * @tc.name : - * @tc.desc : Parse store date from disturbe DB, return is true. - */ -HWTEST_F(NotificationPreferencesDatabaseTest, ParseFromDisturbeDB_00100, Function | SmallTest | Level1) -{ - NotificationPreferencesInfo::BundleInfo bundleInfo; - bundleInfo.SetBundleName(bundleName_); - bundleInfo.SetBundleUid(bundleUid_); - EXPECT_TRUE(preferncesDB_->PutPrivateNotificationsAllowed(bundleInfo, true)); - NotificationPreferencesInfo info; - EXPECT_TRUE(preferncesDB_->ParseFromDisturbeDB(info)); -} - /** * @tc.name : RemoveAllDataFromDisturbeDB_00100 * @tc.number : diff --git a/services/ans/test/unittest/notification_preferences_test.cpp b/services/ans/test/unittest/notification_preferences_test.cpp index 477a52d53..a85425dc0 100644 --- a/services/ans/test/unittest/notification_preferences_test.cpp +++ b/services/ans/test/unittest/notification_preferences_test.cpp @@ -733,82 +733,6 @@ HWTEST_F(NotificationPreferencesTest, GetTotalBadgeNums_00300, Function | SmallT (int)ERR_ANS_INVALID_PARAM); } -/** - * @tc.number : SetPrivateNotificationsAllowed_00100 - * @tc.name : - * @tc.desc : Set private notification allowed badge nums into disturbe DB , return is ERR_OK. - */ -HWTEST_F(NotificationPreferencesTest, SetPrivateNotificationsAllowed_00100, Function | SmallTest | Level1) -{ - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().SetPrivateNotificationsAllowed(bundleOption_, true), (int)ERR_OK); -} - -/** - * @tc.number : SetPrivateNotificationsAllowed_00200 - * @tc.name : - * @tc.desc : Set private notification allowed badge nums into disturbe DB when bundle name is null, return is - * ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, SetPrivateNotificationsAllowed_00200, Function | SmallTest | Level1) -{ - EXPECT_EQ((int)NotificationPreferences::GetInstance().SetPrivateNotificationsAllowed(bundleEmptyOption_, true), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : SetPrivateNotificationsAllowed_00300 - * @tc.name : - * @tc.desc : Set private notification allowed badge nums into disturbe DB when bundleOption is null, return is - * ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, SetPrivateNotificationsAllowed_00300, Function | SmallTest | Level1) -{ - EXPECT_EQ((int)NotificationPreferences::GetInstance().SetPrivateNotificationsAllowed(nullptr, true), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : GetPrivateNotificationsAllowed_00100 - * @tc.name : - * @tc.desc : Get private notification allowed badge nums from disturbe DB, return is ERR_OK. - */ -HWTEST_F(NotificationPreferencesTest, GetPrivateNotificationsAllowed_00100, Function | SmallTest | Level1) -{ - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().SetPrivateNotificationsAllowed(bundleOption_, true), (int)ERR_OK); - bool allow = false; - EXPECT_EQ( - (int)NotificationPreferences::GetInstance().GetPrivateNotificationsAllowed(bundleOption_, allow), (int)ERR_OK); - EXPECT_EQ(allow, true); -} - -/** - * @tc.number : GetPrivateNotificationsAllowed_00200 - * @tc.name : - * @tc.desc : Get private notification allowed badge nums from disturbe DB when bundle is null, return is - * ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, GetPrivateNotificationsAllowed_00200, Function | SmallTest | Level1) -{ - bool allow = false; - EXPECT_EQ((int)NotificationPreferences::GetInstance().GetPrivateNotificationsAllowed(bundleEmptyOption_, allow), - (int)ERR_ANS_INVALID_PARAM); -} - -/** - * @tc.number : GetPrivateNotificationsAllowed_00300 - * @tc.name : - * @tc.desc : Get private notification allowed badge nums from disturbe DB when bundleOption is null, return is - * ERR_ANS_INVALID_PARAM. - */ -HWTEST_F(NotificationPreferencesTest, GetPrivateNotificationsAllowed_00300, Function | SmallTest | Level1) -{ - bool allow = false; - EXPECT_EQ((int)NotificationPreferences::GetInstance().GetPrivateNotificationsAllowed(nullptr, allow), - (int)ERR_ANS_INVALID_PARAM); -} - /** * @tc.number : SetNotificationsEnabledForBundle_00100 * @tc.name : diff --git a/test/bechmarktest/notification_services_test/notification_service_test.cpp b/test/bechmarktest/notification_services_test/notification_service_test.cpp index ed60a4506..e5d4cf335 100644 --- a/test/bechmarktest/notification_services_test/notification_service_test.cpp +++ b/test/bechmarktest/notification_services_test/notification_service_test.cpp @@ -243,44 +243,6 @@ BENCHMARK_F(BenchmarkNotificationService, GetBundleImportanceTestCase)(benchmark } } -/** - * @tc.name: SetPrivateNotificationsAllowedTestCase - * @tc.desc: SetPrivateNotificationsAllowed - * @tc.type: FUNC - * @tc.require: - */ -BENCHMARK_F(BenchmarkNotificationService, SetPrivateNotificationsAllowedTestCase)(benchmark::State &state) -{ - while (state.KeepRunning()) { - ErrCode errCode = advancedNotificationService_->SetPrivateNotificationsAllowed(true); - if (errCode != ERR_OK) { - state.SkipWithError("SetPrivateNotificationsAllowedTestCase failed."); - } - } -} - -/** - * @tc.name: GetPrivateNotificationsAllowedTestCase - * @tc.desc: GetPrivateNotificationsAllowed - * @tc.type: FUNC - * @tc.require: - */ -BENCHMARK_F(BenchmarkNotificationService, GetPrivateNotificationsAllowedTestCase)(benchmark::State &state) -{ - while (state.KeepRunning()) { - ErrCode errCode = advancedNotificationService_->SetPrivateNotificationsAllowed(true); - if (errCode != ERR_OK) { - state.SkipWithError("GetPrivateNotificationsAllowed set failed."); - } - - bool allow = false; - errCode = advancedNotificationService_->GetPrivateNotificationsAllowed(allow); - if (!allow || errCode != ERR_OK) { - state.SkipWithError("GetPrivateNotificationsAllowed get failed."); - } - } -} - /** * @tc.name: SetShowBadgeEnabledForBundleTestCase * @tc.desc: SetShowBadgeEnabledForBundle diff --git a/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp b/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp index 346b645a4..977bc924e 100644 --- a/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp +++ b/test/fuzztest/ansmanagerstub_fuzzer/ansmanagerstub_fuzzer.cpp @@ -60,8 +60,6 @@ namespace OHOS { ansManagerStub.HandlePublishContinuousTaskNotification(datas, reply); ansManagerStub.HandleCancelContinuousTaskNotification(datas, reply); ansManagerStub.HandleIsNotificationPolicyAccessGranted(datas, reply); - ansManagerStub.HandleSetPrivateNotificationsAllowed(datas, reply); - ansManagerStub.HandleGetPrivateNotificationsAllowed(datas, reply); ansManagerStub.HandleRemoveNotification(datas, reply); ansManagerStub.HandleRemoveAllNotifications(datas, reply); ansManagerStub.HandleDelete(datas, reply); @@ -145,8 +143,6 @@ namespace OHOS { ansManagerStub.GetBundleImportance(importance); bool granted = true; ansManagerStub.HasNotificationPolicyAccessPermission(granted); - bool allow = true; - ansManagerStub.SetPrivateNotificationsAllowed(allow); int32_t removeReason = 1; ansManagerStub.RemoveNotification(bundleOption, notificationId, label, removeReason); ansManagerStub.RemoveAllNotifications(bundleOption); diff --git a/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.cpp b/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.cpp index 712eab912..9d36e9e4b 100644 --- a/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.cpp +++ b/test/fuzztest/ansmanagerstubannexthree_fuzzer/ansmanagerstubannexthree_fuzzer.cpp @@ -29,7 +29,6 @@ namespace OHOS { { Notification::AnsManagerStub ansManagerStub; bool allow = *data % ENABLE; - ansManagerStub.GetPrivateNotificationsAllowed(allow); sptr bundleOption = new Notification::NotificationBundleOption(); int notificationId = 1; std::string stringData(data); diff --git a/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.cpp b/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.cpp index bece687cf..e475ab2f1 100644 --- a/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.cpp +++ b/test/fuzztest/ansmanagerstubannextwo_fuzzer/ansmanagerstubannextwo_fuzzer.cpp @@ -76,7 +76,7 @@ namespace OHOS { ansManagerStub.SetNotificationBadgeNum(notificationId); ansManagerStub.GetBundleImportance(notificationId); ansManagerStub.HasNotificationPolicyAccessPermission(canPublish); - return ansManagerStub.SetPrivateNotificationsAllowed(canPublish); + return true; } } -- Gitee