• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "ani_remove_group.h"
17 
18 #include "ans_log_wrapper.h"
19 #include "notification_helper.h"
20 #include "sts_common.h"
21 #include "sts_throw_erro.h"
22 #include "sts_bundle_option.h"
23 #include "notification_helper.h"
24 
25 namespace OHOS {
26 namespace NotificationManagerSts {
27 
AniRemoveGroupByBundle(ani_env * env,ani_object bundleOption,ani_string groupName)28 void AniRemoveGroupByBundle(ani_env *env, ani_object bundleOption, ani_string groupName)
29 {
30     ANS_LOGD("AniRemoveGroupByBundle call");
31     OHOS::Notification::NotificationBundleOption option;
32     if (!OHOS::NotificationSts::UnwrapBundleOption(env, bundleOption, option)) {
33         NotificationSts::ThrowErrorWithMsg(env, "sts AniRemoveGroupByBundle ERROR_INTERNAL_ERROR");
34         return ;
35     }
36     std::string tempStr = "";
37     ani_status status = NotificationSts::GetStringByAniString(env, groupName, tempStr);
38     if (status !=  ANI_OK) {
39         NotificationSts::ThrowErrorWithMsg(env, "sts AniRemoveGroupByBundle ERROR_INTERNAL_ERROR");
40         return ;
41     }
42     std::string groupNameStr = NotificationSts::GetResizeStr(tempStr, NotificationSts::STR_MAX_SIZE);
43     int returncode = OHOS::Notification::NotificationHelper::RemoveGroupByBundle(option, groupNameStr);
44     if (returncode != ERR_OK) {
45         int externalCode = NotificationSts::GetExternalCode(returncode);
46         ANS_LOGE("AniRemoveGroupByBundle -> error, errorCode: %{public}d", externalCode);
47         OHOS::NotificationSts::ThrowError(env, externalCode, NotificationSts::FindAnsErrMsg(externalCode));
48     }
49     ANS_LOGD("AniRemoveGroupByBundle end");
50 }
51 }
52 }