diff --git a/frameworks/ans/test/unittest/notification_helper_test.cpp b/frameworks/ans/test/unittest/notification_helper_test.cpp index 5a9634c7746b5284c9f883de769cc971d4f725ad..52014e4a33cda52e0d3821f19ae0a89528a4dee0 100644 --- a/frameworks/ans/test/unittest/notification_helper_test.cpp +++ b/frameworks/ans/test/unittest/notification_helper_test.cpp @@ -48,7 +48,7 @@ HWTEST_F(NotificationHelperTest, AddNotificationSlot_00001, Function | SmallTest NotificationSlot slot; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.AddNotificationSlot(slot); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -249,7 +249,7 @@ HWTEST_F(NotificationHelperTest, CancelAsBundle_00001, Function | SmallTest | Le int32_t userId = 10; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.CancelAsBundle(notificationId, representativeBundle, userId); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_UID); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -390,7 +390,7 @@ HWTEST_F(NotificationHelperTest, IsAllowedNotify_00001, Function | SmallTest | L bool allowed = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.IsAllowedNotify(allowed); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -476,7 +476,7 @@ HWTEST_F(NotificationHelperTest, RemoveNotification_00001, Function | SmallTest int32_t removeReason = 2; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.RemoveNotification(key, removeReason); - EXPECT_EQ(ret, (int)ERR_ANS_NOTIFICATION_NOT_EXISTS); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -534,7 +534,7 @@ HWTEST_F(NotificationHelperTest, RemoveNotifications_00001, Function | SmallTest { NotificationHelper notificationHelper; ErrCode ret = notificationHelper.RemoveNotifications(); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -578,7 +578,7 @@ HWTEST_F(NotificationHelperTest, GetAllActiveNotifications_00001, Function | Sma std::vector> notification; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetAllActiveNotifications(notification); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -623,7 +623,7 @@ HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00001, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(deviceId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -725,7 +725,7 @@ HWTEST_F(NotificationHelperTest, SetDoNotDisturbDate_00001, Function | SmallTest NotificationDoNotDisturbDate doNotDisturbDate; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -739,7 +739,7 @@ HWTEST_F(NotificationHelperTest, GetDoNotDisturbDate_00001, Function | SmallTest NotificationDoNotDisturbDate doNotDisturbDate; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetDoNotDisturbDate(doNotDisturbDate); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -753,7 +753,7 @@ HWTEST_F(NotificationHelperTest, DoesSupportDoNotDisturbMode_00001, Function | S bool doesSupport = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.DoesSupportDoNotDisturbMode(doesSupport); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -781,7 +781,7 @@ HWTEST_F(NotificationHelperTest, EnableDistributed_00001, Function | SmallTest | bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.EnableDistributed(enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -796,7 +796,7 @@ HWTEST_F(NotificationHelperTest, EnableDistributedByBundle_00001, Function | Sma bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.EnableDistributedByBundle(bundleOption, enabled); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -825,7 +825,7 @@ HWTEST_F(NotificationHelperTest, IsDistributedEnableByBundle_00001, Function | S bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.IsDistributedEnableByBundle(bundleOption, enabled); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -839,7 +839,7 @@ HWTEST_F(NotificationHelperTest, GetDeviceRemindType_00001, Function | SmallTest NotificationConstant::RemindType remindType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetDeviceRemindType(remindType); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -868,7 +868,7 @@ HWTEST_F(NotificationHelperTest, CancelContinuousTaskNotification_00001, Functio int32_t notificationId = 10; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.CancelContinuousTaskNotification(label, notificationId); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_NOT_SYSTEM_SERVICE); } /** @@ -898,7 +898,7 @@ HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00002, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(userId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -928,7 +928,7 @@ HWTEST_F(NotificationHelperTest, IsAllowedNotify_00004, Function | SmallTest | L bool allowed = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.IsAllowedNotify(userId, allowed); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -943,7 +943,7 @@ HWTEST_F(NotificationHelperTest, SetNotificationsEnabledForAllBundles_00003, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetNotificationsEnabledForAllBundles(userId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -972,7 +972,7 @@ HWTEST_F(NotificationHelperTest, SetDoNotDisturbDate_00002, Function | SmallTest NotificationDoNotDisturbDate doNotDisturbDate; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -987,7 +987,7 @@ HWTEST_F(NotificationHelperTest, GetDoNotDisturbDate_00002, Function | SmallTest NotificationDoNotDisturbDate doNotDisturbDate; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetDoNotDisturbDate(userId, doNotDisturbDate); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -1034,7 +1034,7 @@ HWTEST_F(NotificationHelperTest, SetSyncNotificationEnabledWithoutApp_00001, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.SetSyncNotificationEnabledWithoutApp(userId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** @@ -1049,7 +1049,7 @@ HWTEST_F(NotificationHelperTest, GetSyncNotificationEnabledWithoutApp_00001, Fun bool enabled = true; NotificationHelper notificationHelper; ErrCode ret = notificationHelper.GetSyncNotificationEnabledWithoutApp(userId, enabled); - EXPECT_EQ(ret, (int)ERR_OK); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } } } \ No newline at end of file diff --git a/frameworks/ans/test/unittest/reminder_helper_test.cpp b/frameworks/ans/test/unittest/reminder_helper_test.cpp index 549c42cb19ba10c8f40270fec63cb847aa76fcc1..22b93e4432ac814983218ce76f58d86d3c9721b7 100644 --- a/frameworks/ans/test/unittest/reminder_helper_test.cpp +++ b/frameworks/ans/test/unittest/reminder_helper_test.cpp @@ -101,7 +101,7 @@ HWTEST_F(ReminderHelperTest, AddNotificationSlot_00001, Function | SmallTest | L NotificationSlot slot; ReminderHelper reminderHelper; ErrCode ret = reminderHelper.AddNotificationSlot(slot); - EXPECT_EQ(ret, (int)ERR_ANS_INVALID_BUNDLE); + EXPECT_EQ(ret, (int)ERR_ANS_PERMISSION_DENIED); } /** diff --git a/services/ans/src/access_token_helper.cpp b/services/ans/src/access_token_helper.cpp index 56c226c69dcd675a042caa05255a4efd49871cf1..ed32d526425d2e6546d1c4a474a3a27b2de3f8c9 100644 --- a/services/ans/src/access_token_helper.cpp +++ b/services/ans/src/access_token_helper.cpp @@ -32,7 +32,7 @@ bool AccessTokenHelper::VerifyCallerPermission( bool AccessTokenHelper::VerifyNativeToken(const AccessTokenID &callerToken) { ATokenTypeEnum tokenType = AccessTokenKit::GetTokenTypeFlag(callerToken); - return (tokenType == ATokenTypeEnum::TOKEN_NATIVE || tokenType == ATokenTypeEnum::TOKEN_SHELL); + return (tokenType == ATokenTypeEnum::TOKEN_NATIVE); } bool AccessTokenHelper::IsSystemHap() diff --git a/tools/dump/include/notification_shell_command.h b/tools/dump/include/notification_shell_command.h index a295ce410e0d349fcf80feb5d6d905c3380ed1af..5e8d07f210c322d72e650e633fba144056770ef7 100644 --- a/tools/dump/include/notification_shell_command.h +++ b/tools/dump/include/notification_shell_command.h @@ -49,7 +49,6 @@ private: ErrCode RunDumpCmd(const std::string& cmd, const std::string& bundle, int32_t userId, std::vector &infos); ErrCode RunSetEnableCmd(); - void SetNativeToken(); private: std::shared_ptr ans_; diff --git a/tools/dump/src/notification_shell_command.cpp b/tools/dump/src/notification_shell_command.cpp index 1d4b04f71e30f1beeadfbc67a961bb49344c0f5f..a3bc770b1153f3a22c8d3dfb5714e690a03d54d2 100644 --- a/tools/dump/src/notification_shell_command.cpp +++ b/tools/dump/src/notification_shell_command.cpp @@ -93,7 +93,6 @@ ErrCode NotificationShellCommand::CreateCommandMap() ErrCode NotificationShellCommand::Init() { - SetNativeToken(); ErrCode result = OHOS::ERR_OK; if (!ans_) { ans_ = DelayedSingleton::GetInstance(); @@ -104,27 +103,6 @@ ErrCode NotificationShellCommand::Init() return result; } -void NotificationShellCommand::SetNativeToken() -{ - uint64_t tokenId; - const char **perms = new const char *[1]; - perms[0] = "ohos.permission.NOTIFICATION_CONTROLLER"; - NativeTokenInfoParams infoInstance = { - .dcapsNum = 0, - .permsNum = 1, - .aclsNum = 0, - .dcaps = nullptr, - .perms = perms, - .acls = nullptr, - .aplStr = "system_basic", - }; - - infoInstance.processName = "anm"; - tokenId = GetAccessTokenId(&infoInstance); - SetSelfTokenID(tokenId); - delete[] perms; -} - ErrCode NotificationShellCommand::RunAsHelpCommand() { resultReceiver_.append(HELP_MSG);