• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 * Copyright (c) 2021-2024 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 "notification_app_privileges.h"
17 
18 namespace OHOS {
19 namespace Notification {
NotificationAppPrivileges(const std::string & flagStr)20 NotificationAppPrivileges::NotificationAppPrivileges(const std::string &flagStr)
21 {
22     if (flagStr.size() > LIVE_VIEW_ENABLED_SEQ &&
23         flagStr[LIVE_VIEW_ENABLED_SEQ] == LIVE_VIEW_ENABLE) {
24         privileges_ |= 1 << LIVE_VIEW_ENABLED_SEQ;
25     }
26     if (flagStr.size() > BANNER_ENABLED_SEQ &&
27         flagStr[BANNER_ENABLED_SEQ] == BANNER_ENABLE) {
28         privileges_ |= 1 << BANNER_ENABLED_SEQ;
29     }
30     if (flagStr.size() > REMINDER_ENABLED_SEQ &&
31         flagStr[REMINDER_ENABLED_SEQ] == REMINDER_ENABLE) {
32         privileges_ |= 1 << REMINDER_ENABLED_SEQ;
33     }
34     if (flagStr.size() > DISTRIBUTED_REPLY_SEQ &&
35         flagStr[DISTRIBUTED_REPLY_SEQ] == DISTRIBUTED_REPLY_ENABLE) {
36         privileges_ |= 1 << DISTRIBUTED_REPLY_SEQ;
37     }
38 }
39 
IsLiveViewEnabled() const40 bool NotificationAppPrivileges::IsLiveViewEnabled() const
41 {
42     if ((privileges_ & (1 << LIVE_VIEW_ENABLED_SEQ)) != 0) {
43         return true;
44     }
45     return false;
46 }
IsBannerEnabled() const47 bool NotificationAppPrivileges::IsBannerEnabled() const
48 {
49     if ((privileges_ & (1 << BANNER_ENABLED_SEQ)) != 0) {
50         return true;
51     }
52     return false;
53 }
IsReminderEnabled() const54 bool NotificationAppPrivileges::IsReminderEnabled() const
55 {
56     if ((privileges_ & (1 << REMINDER_ENABLED_SEQ)) != 0) {
57         return true;
58     }
59     return false;
60 }
IsDistributedReplyEnabled() const61 bool NotificationAppPrivileges::IsDistributedReplyEnabled() const
62 {
63     if ((privileges_ & (1 << DISTRIBUTED_REPLY_SEQ)) != 0) {
64         return true;
65     }
66     return false;
67 }
68 } // namespace Notification
69 } // namespace OHOS
70