• 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 CALL_NUMBER_UTILS_H
17 #define CALL_NUMBER_UTILS_H
18 
19 #include "pac_map.h"
20 #include "singleton.h"
21 #include "phonenumberutil.h"
22 
23 #include "common_type.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 class CallNumberUtils {
28     DECLARE_DELAYED_SINGLETON(CallNumberUtils)
29 public:
30     int32_t FormatPhoneNumber(
31         const std::string &phoneNumber, const std::string &countryCode, std::string &formatNumber);
32     int32_t FormatPhoneNumberToE164(
33         const std::string phoneNumber, const std::string countryCode, std::string &formatNumber);
34     int32_t FormatPhoneNumberToNational(
35         const std::string phoneNumber, const std::string countryCode, std::string &formatNumber);
36     int32_t FormatPhoneNumberToInternational(
37         const std::string phoneNumber, const std::string countryCode, std::string &formatNumber);
38     int32_t FormatNumberBase(const std::string phoneNumber, std::string countryCode,
39         const i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat formatInfo, std::string &formatNumber);
40     int32_t CheckNumberIsEmergency(const std::string &phoneNumber, const int32_t slotId, bool &enabled);
41     bool IsValidSlotId(int32_t slotId) const;
42     bool IsMMICode(const std::string &number);
43     bool RegexMatchMmi(const std::string &number);
44     std::string RemoveSeparatorsPhoneNumber(const std::string &phoneString);
45     std::string RemovePostDialPhoneNumber(const std::string &phoneString);
46     bool HasAlphabetInPhoneNum(const std::string &inputValue);
47     bool HasBCPhoneNumber(const std::string &phoneNumber);
48 
49 private:
50     void ProcessSpace(std::string &number);
51 
52 private:
53     static const int16_t HAS_A_SLOT = 1;
54     static const int16_t HAS_TWO_SLOT = 2;
55 };
56 } // namespace Telephony
57 } // namespace OHOS
58 
59 #endif // CALL_NUMBER_UTILS_H