• 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 #ifndef TELEPHONY_CALL_EDM_CALL_POLICY_H
17 #define TELEPHONY_CALL_EDM_CALL_POLICY_H
18 
19 #include <unordered_set>
20 #include "ffrt.h"
21 
22 namespace OHOS {
23 namespace Telephony {
24 
25 enum EdmPolicyFlag : int32_t {
26     POLICY_FLAG_NONE = -1,  // 无策略
27     POLICY_FLAG_BLOCK = 0,  // 黑名单
28     POLICY_FLAG_TRUST = 1,  // 白名单
29 };
30 
31 struct EdmCallPolicyList {
32     EdmPolicyFlag policyFlag { EdmPolicyFlag::POLICY_FLAG_NONE };
33     std::unordered_set<std::string> numberList {};
34 };
35 
36 class EdmCallPolicy {
37 public:
38     EdmCallPolicy();
39     ~EdmCallPolicy();
40     int32_t SetCallPolicy(bool isDialingTrustlist, const std::vector<std::string> &dialingList,
41         bool isIncomingTrustlist, const std::vector<std::string> &incomingList);
42     bool IsDialingEnable(const std::string &phoneNum);
43     bool IsIncomingEnable(const std::string &phoneNum);
44 
45 private:
46     bool IsCallEnable(const std::string &phoneNum, const EdmCallPolicyList &list);
47     ffrt::shared_mutex rwMutex_{};
48     EdmCallPolicyList dialingList_{};
49     EdmCallPolicyList incomingList_{};
50 };
51 } // namespace Telephony
52 } // namespace OHOS
53 #endif // TELEPHONY_CALL_EDM_CALL_POLICY_H