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 FormatNumberBase(const std::string phoneNumber, std::string countryCode, 35 const i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat formatInfo, std::string &formatNumber); 36 int32_t CheckNumberIsEmergency(const std::string &phoneNumber, const int32_t slotId, bool &enabled); 37 bool IsValidSlotId(int32_t slotId) const; 38 bool IsMMICode(const std::string &number); 39 bool RegexMatchMmi(const std::string &number); 40 std::string RemoveSeparatorsPhoneNumber(const std::string &phoneString); 41 std::string RemovePostDailPhoneNumber(const std::string &phoneString); 42 43 private: 44 static const int16_t HAS_A_SLOT = 1; 45 static const int16_t HAS_TWO_SLOT = 2; 46 }; 47 } // namespace Telephony 48 } // namespace OHOS 49 50 #endif // CALL_NUMBER_UTILS_H