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 #include "plmn_file.h"
16
17 namespace OHOS {
18 namespace Telephony {
PlmnFile(unsigned char * bytes,int offset)19 PlmnFile::PlmnFile(unsigned char *bytes, int offset)
20 {
21 this->plmn_ = SIMUtils::BcdPlmnConvertToString("", offset);
22 const char *plmnData = reinterpret_cast<const char *>(bytes);
23 uint32_t aValue = static_cast<uint32_t>(atoi(plmnData + offset + OFFSET_A));
24 uint32_t bValue = static_cast<uint32_t>(atoi(plmnData + offset + OFFSET_B));
25 this->rat_ = (aValue << OFFSET_ALL) | bValue;
26 }
27
PlmnFile(const std::string & plmn,int accessTechs)28 PlmnFile::PlmnFile(const std::string &plmn, int accessTechs) : plmn_(plmn), rat_(accessTechs) {}
29
ReadFromParcel(Parcel & parcel)30 bool PlmnFile::ReadFromParcel(Parcel &parcel)
31 {
32 return true;
33 }
34
Marshalling(Parcel & parcel) const35 bool PlmnFile::Marshalling(Parcel &parcel) const
36 {
37 if (!parcel.WriteCString(plmn_.c_str())) {
38 TELEPHONY_LOGE("PlmnFile::Marshalling write source plmn_ to parcel failed");
39 return false;
40 }
41 if (!parcel.WriteInt32(rat_)) {
42 TELEPHONY_LOGE("PlmnFile::Marshalling write source rat_ to parcel failed");
43 return false;
44 }
45 return true;
46 }
47
~PlmnFile()48 PlmnFile::~PlmnFile() {}
49
UnMarshalling(Parcel & parcel)50 PlmnFile *PlmnFile::UnMarshalling(Parcel &parcel)
51 {
52 return nullptr;
53 }
54 } // namespace Telephony
55 } // namespace OHOS
56