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#include "call_base.h" 25 26namespace OHOS { 27namespace Telephony { 28class CallNumberUtils { 29 DECLARE_DELAYED_SINGLETON(CallNumberUtils) 30public: 31 int32_t FormatPhoneNumber( 32 const std::string &phoneNumber, const std::string &countryCode, std::string &formatNumber); 33 int32_t FormatPhoneNumberToE164( 34 const std::string phoneNumber, const std::string countryCode, std::string &formatNumber); 35 int32_t FormatPhoneNumberToNational( 36 const std::string phoneNumber, const std::string countryCode, std::string &formatNumber); 37 int32_t FormatPhoneNumberToInternational( 38 const std::string phoneNumber, const std::string countryCode, std::string &formatNumber); 39 int32_t FormatNumberBase(const std::string phoneNumber, std::string countryCode, 40 const i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat formatInfo, std::string &formatNumber); 41 int32_t FormatPhoneNumberAsYouType( 42 const std::string &phoneNumber, const std::string &countryCode, std::string &formatNumber); 43 int32_t CheckNumberIsEmergency(const std::string &phoneNumber, const int32_t slotId, bool &enabled); 44 bool IsValidSlotId(int32_t slotId) const; 45 bool IsMMICode(const std::string &number); 46 bool RegexMatchMmi(const std::string &number); 47 std::string RemoveSeparatorsPhoneNumber(const std::string &phoneString); 48 std::string RemovePostDialPhoneNumber(const std::string &phoneString); 49 bool HasAlphabetInPhoneNum(const std::string &inputValue); 50 bool HasBCPhoneNumber(const std::string &phoneNumber); 51 bool SelectAccountId(int32_t slotId, AppExecFwk::PacMap &extras); 52 int32_t QueryNumberLocationInfo(std::string &numberLocation, std::string accountNumber); 53 void NumberLocationUpdate(const sptr<CallBase> &callObjectPtr); 54 int32_t QueryYellowPageAndMarkInfo(NumberMarkInfo &numberMarkInfo, std::string accountNumber); 55 void YellowPageAndMarkUpdate(const sptr<CallBase> &callObjectPtr); 56private: 57 void ProcessSpace(std::string &number); 58 59private: 60 static const int16_t HAS_A_SLOT = 1; 61 static const int16_t HAS_TWO_SLOT = 2; 62}; 63} // namespace Telephony 64} // namespace OHOS 65 66#endif // CALL_NUMBER_UTILS_H