• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 #ifndef TELEPHONY_PERMISSION_H
17 #define TELEPHONY_PERMISSION_H
18 
19 #include <string>
20 
21 namespace OHOS {
22 namespace Telephony {
23 namespace Permission {
24 /**
25  * This permission indicates being allowed to place an outgoing call.
26  */
27 static constexpr const char *PLACE_CALL = "ohos.permission.PLACE_CALL";
28 /**
29  * This permission indicates being allowed to answer an incoming call.
30  */
31 static constexpr const char *ANSWER_CALL = "ohos.permission.ANSWER_CALL";
32 /**
33  * This permission indicates being allowed to write user's call log data.
34  */
35 static constexpr const char *WRITE_CALL_LOG = "ohos.permission.WRITE_CALL_LOG";
36 /**
37  * This permission indicates being allowed to read user's call log data.
38  */
39 static constexpr const char *READ_CALL_LOG = "ohos.permission.READ_CALL_LOG";
40 /**
41  * This permission indicates being allowed to write user's calendar data.
42  */
43 static constexpr const char *WRITE_CALENDAR = "ohos.permission.WRITE_CALENDAR";
44 /**
45  * This permission indicates being allowed to read cell messages.
46  */
47 static constexpr const char *READ_CELL_MESSAGES = "ohos.permission.READ_CELL_MESSAGES";
48 /**
49  * This permission indicates being allowed to write user's contacts data.
50  */
51 static constexpr const char *WRITE_CONTACTS = "ohos.permission.WRITE_CONTACTS";
52 /**
53  * This permission indicates being allowed to read user's contacts data.
54  */
55 static constexpr const char *READ_CONTACTS = "ohos.permission.READ_CONTACTS";
56 /**
57  * This permission indicates being allowed to set state of telephony.
58  */
59 static constexpr const char *SET_TELEPHONY_STATE = "ohos.permission.SET_TELEPHONY_STATE";
60 /**
61  * This permission indicates being allowed to get state of telephony.
62  */
63 static constexpr const char *GET_TELEPHONY_STATE = "ohos.permission.GET_TELEPHONY_STATE";
64 /**
65  * This permission indicates being allowed to get MSISDN of SIM card.
66  */
67 static constexpr const char *GET_PHONE_NUMBERS = "ohos.permission.GET_PHONE_NUMBERS";
68 /**
69  * This permission indicates being allowed to set information about network.
70  */
71 static constexpr const char *SET_NETWORK_INFO = "ohos.permission.SET_NETWORK_INFO";
72 /**
73  * This permission indicates being allowed to get information about network.
74  */
75 static constexpr const char *GET_NETWORK_INFO = "ohos.permission.GET_NETWORK_INFO";
76 /**
77  * This permission indicates being allowed to access cell loaction.
78  */
79 static constexpr const char *CELL_LOCATION = "ohos.permission.LOCATION";
80 /**
81  * This permission indicates being allowed to read messages.
82  */
83 static constexpr const char *READ_MESSAGES = "ohos.permission.READ_MESSAGES";
84 /**
85  * This permission indicates being allowed to send messages.
86  */
87 static constexpr const char *SEND_MESSAGES = "ohos.permission.SEND_MESSAGES";
88 /**
89  * This permission indicates being allowed to receive sms messages.
90  */
91 static constexpr const char *RECEIVE_MESSAGES = "ohos.permission.RECEIVE_SMS";
92 /**
93  * This permission indicates being allowed to connect cellular call service.
94  */
95 static constexpr const char *CONNECT_CELLULAR_CALL_SERVICE = "ohos.permission.CONNECT_CELLULAR_CALL_SERVICE";
96 /**
97  * This permission indicates being allowed to connect IMS service.
98  */
99 static constexpr const char *CONNECT_IMS_SERVICE = "ohos.permission.CONNECT_IMS_SERVICE";
100 /**
101  * This permission indicates being allowed to receive mms.
102  */
103 static constexpr const char *RECEIVE_MMS = "ohos.permission.RECEIVE_MMS";
104 } // namespace Permission
105 
106 class TelephonyPermission {
107 public:
108     /**
109      * @brief Permission check by callingUid.
110      *
111      * @param permissionName permission name.
112      * @return Return {@code true} on success, {@code false} on failure.
113      */
114     static bool CheckPermission(const std::string &permissionName);
115 
116     /**
117      * @brief Get bundleName by callingUid.
118      *
119      * @param callingUid.
120      * @param bundleName.
121      * @return Return {@code true} on success, {@code false} on failure.
122      */
123     static bool GetBundleNameByUid(int32_t uid, std::string &bundleName);
124 
125     /**
126      * @brief Check if the caller is System App.
127      *
128      * @return Return {@code true} if the caller is System App, return {@code false} otherwise.
129      */
130     static bool CheckCallerIsSystemApp();
131 };
132 } // namespace Telephony
133 } // namespace OHOS
134 #endif // TELEPHONY_PERMISSION_H
135