1 /*
2 * Copyright (c) 2023 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 #include "vcard_configuration.h"
17
18 namespace OHOS {
19 namespace Telephony {
20 namespace {
21 std::vector<int32_t> sJapaneseMobileTypeList = { VCardConfiguration::VCARD_TYPE_V21_JAPANESE,
22 VCardConfiguration::VCARD_TYPE_V30_JAPANESE, VCardConfiguration::VCARD_TYPE_V21_JAPANESE_MOBILE,
23 VCardConfiguration::VCARD_TYPE_DOCOMO };
24 }
25
IsVer21(const int32_t vcardType)26 bool VCardConfiguration::IsVer21(const int32_t vcardType)
27 {
28 return (static_cast<uint32_t>(vcardType) & VER_FLAG) == VER_21;
29 }
30
IsVer30(const int32_t vcardType)31 bool VCardConfiguration::IsVer30(const int32_t vcardType)
32 {
33 return (static_cast<uint32_t>(vcardType) & VER_FLAG) == VER_30;
34 }
35
IsVer40(const int32_t vcardType)36 bool VCardConfiguration::IsVer40(const int32_t vcardType)
37 {
38 return (static_cast<uint32_t>(vcardType) & VER_FLAG) == VER_40;
39 }
40
RefrainPhoneNumberFormatting(const int32_t vcardType)41 bool VCardConfiguration::RefrainPhoneNumberFormatting(const int32_t vcardType)
42 {
43 return ((static_cast<uint32_t>(vcardType) & FLAG_REFRAIN_PHONE_NUMBER_FORMATTING) != 0);
44 }
45
IsJapaneseDevice(const int32_t vcardType)46 bool VCardConfiguration::IsJapaneseDevice(const int32_t vcardType)
47 {
48 bool contains = false;
49 if (std::find(sJapaneseMobileTypeList.begin(), sJapaneseMobileTypeList.end(), vcardType) !=
50 sJapaneseMobileTypeList.end()) {
51 contains = true;
52 }
53 return contains;
54 }
55 } // namespace Telephony
56 } // namespace OHOS
57