• 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 "call_base.h"
24 #include "common_type.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 /**
29  * 3GPP TS 22.030 V4.0.0 (2001-03)  6.5.2 Structure of the MMI
30  * The following sequence of functions shall be used for the control of Supplementary Services:
31  *  SELECT:	Entry of the procedure information (may be a digit or a sequence of characters).
32  *  SEND:	Transmission of the information to the network.
33  *  INDICATION:	Call progress indications.
34  */
35 struct MMIData {
36     std::string actionString = "";
37     std::string serviceCode = "";
38     std::string dialString = "";
39 };
40 
41 class CallNumberUtils {
42     DECLARE_DELAYED_SINGLETON(CallNumberUtils)
43 public:
44     int32_t FormatPhoneNumber(
45         const std::string &phoneNumber, const std::string &countryCode, std::string &formatNumber);
46     int32_t FormatPhoneNumberToE164(
47         const std::string phoneNumber, const std::string countryCode, std::string &formatNumber);
48     int32_t FormatPhoneNumberToNational(
49         const std::string phoneNumber, const std::string countryCode, std::string &formatNumber);
50     int32_t FormatPhoneNumberToInternational(
51         const std::string phoneNumber, const std::string countryCode, std::string &formatNumber);
52     int32_t FormatNumberBase(const std::string phoneNumber, std::string countryCode,
53         const i18n::phonenumbers::PhoneNumberUtil::PhoneNumberFormat formatInfo, std::string &formatNumber);
54     int32_t FormatPhoneNumberAsYouType(
55         const std::string &phoneNumber, const std::string &countryCode, std::string &formatNumber);
56     int32_t CheckNumberIsEmergency(const std::string &phoneNumber, const int32_t slotId, bool &enabled);
57     bool IsValidSlotId(int32_t slotId) const;
58     int32_t IsCarrierVtConfig(const int32_t slotId, bool &enabled);
59     bool IsMMICode(std::string &number);
60     bool RegexMatchMmi(const std::string &number);
61     std::string RemoveSeparatorsPhoneNumber(const std::string &phoneString);
62     std::string RemovePostDialPhoneNumber(const std::string &phoneString);
63     bool HasAlphabetInPhoneNum(const std::string &inputValue);
64     bool HasBCPhoneNumber(const std::string &phoneNumber);
65     bool SelectAccountId(int32_t slotId, AppExecFwk::PacMap &extras);
66     int32_t QueryNumberLocationInfo(std::string &numberLocation, std::string accountNumber);
67     void NumberLocationUpdate(const sptr<CallBase> &callObjectPtr);
68     int32_t QueryYellowPageAndMarkInfo(NumberMarkInfo &numberMarkInfo, std::string accountNumber);
69     void YellowPageAndMarkUpdate(const sptr<CallBase> &callObjectPtr);
70 private:
71     void ProcessSpace(std::string &number);
72     bool IsShortCode(const std::string &number);
73     bool IsShortCodeWithCellularCall(const std::string &number);
74     bool IsShortCodeWithoutCellularCall(const std::string &number);
75 
76 private:
77     static const int16_t HAS_A_SLOT = 1;
78     static const int16_t HAS_TWO_SLOT = 2;
79     MMIData mmiData_;
80 };
81 } // namespace Telephony
82 } // namespace OHOS
83 
84 #endif // CALL_NUMBER_UTILS_H