ril_adapter芯片组件独立编译

Signed-off-by: ASheLock <zhoujie223@huawei.com>
This commit is contained in:
ASheLock 2024-04-01 14:43:01 +08:00
parent a3d7ce5fdb
commit c5882d9e5b
21 changed files with 22 additions and 2665 deletions

View File

@ -56,14 +56,20 @@
"header_files": [] "header_files": []
}, },
"name":"//base/telephony/ril_adapter/services/hril_hdf:hril_hdf" "name":"//base/telephony/ril_adapter/services/hril_hdf:hril_hdf"
} },
,
{ {
"header": { "header": {
"header_base" : "//base/telephony/ril_adapter/services/hril/include", "header_base" : "//base/telephony/ril_adapter/services/hril/include",
"header_files": [] "header_files": []
}, },
"name":"//base/telephony/ril_adapter/services/hril:hril" "name":"//base/telephony/ril_adapter/services/hril:hril"
},
{
"header": {
"header_base" : "//base/telephony/ril_adapter/interfaces/innerkits/include",
"header_files": []
},
"name" : "//base/telephony/ril_adapter/interfaces/innerkits:hril_innerkits"
} }
], ],
"test": [ "test": [

View File

@ -1,173 +0,0 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "hril_base_parcel.h"
namespace OHOS {
namespace Telephony {
namespace BaseParcel {
bool Read(Parcel &parcel, int8_t &value)
{
return parcel.ReadInt8(value);
}
bool Read(Parcel &parcel, uint8_t &value)
{
return parcel.ReadUint8(value);
}
bool Read(Parcel &parcel, int32_t &value)
{
return parcel.ReadInt32(value);
}
bool Read(Parcel &parcel, uint32_t &value)
{
return parcel.ReadUint32(value);
}
bool Read(Parcel &parcel, int64_t &value)
{
return parcel.ReadInt64(value);
}
bool Read(Parcel &parcel, uint64_t &value)
{
return parcel.ReadUint64(value);
}
bool Read(Parcel &parcel, bool &value)
{
return parcel.ReadBool(value);
}
bool Read(Parcel &parcel, std::string &value)
{
return parcel.ReadString(value);
}
bool Write(Parcel &parcel, const int8_t &value)
{
return parcel.WriteInt8(value);
}
bool Write(Parcel &parcel, const uint8_t &value)
{
return parcel.WriteUint8(value);
}
bool Write(Parcel &parcel, const int32_t &value)
{
return parcel.WriteInt32(value);
}
bool Write(Parcel &parcel, const uint32_t &value)
{
return parcel.WriteUint32(value);
}
bool Write(Parcel &parcel, const int64_t &value)
{
return parcel.WriteInt64(value);
}
bool Write(Parcel &parcel, const uint64_t &value)
{
return parcel.WriteUint64(value);
}
bool Write(Parcel &parcel, const bool &value)
{
return parcel.WriteBool(value);
}
bool Write(Parcel &parcel, const std::string &value)
{
return parcel.WriteString(value);
}
} // BaseParcel
bool HrilBaseParcel::ReadBaseUint8(Parcel &parcel, uint8_t &value)
{
return parcel.ReadUint8(value);
}
bool HrilBaseParcel::ReadBaseInt32(Parcel &parcel, int32_t &value)
{
return parcel.ReadInt32(value);
}
bool HrilBaseParcel::ReadBaseInt64(Parcel &parcel, int64_t &value)
{
return parcel.ReadInt64(value);
}
bool HrilBaseParcel::ReadBaseBool(Parcel &parcel, bool &value)
{
return parcel.ReadBool(value);
}
bool HrilBaseParcel::ReadBaseString(Parcel &parcel, std::string &value)
{
return parcel.ReadString(value);
}
bool HrilBaseParcel::WriteBaseUint8(Parcel &parcel, uint8_t value) const
{
return parcel.WriteUint8(value);
}
bool HrilBaseParcel::WriteBaseInt32(Parcel &parcel, int32_t value) const
{
return parcel.WriteInt32(value);
}
bool HrilBaseParcel::WriteBaseInt64(Parcel &parcel, int64_t value) const
{
return parcel.WriteInt64(value);
}
bool HrilBaseParcel::WriteBaseBool(Parcel &parcel, bool value) const
{
return parcel.WriteBool(value);
}
bool HrilBaseParcel::WriteBaseString(Parcel &parcel, std::string value) const
{
return parcel.WriteString(value);
}
std::stringstream &HrilBaseParcel::StringStream(void) const
{
thread_local std::stringstream ss;
ss.str("");
return ss;
}
std::string &HrilBaseParcel::String(void) const
{
thread_local std::string out = "";
out = "";
return out;
}
const char *HrilBaseParcel::ToString(void) const
{
std::string &str = String();
str = "[omitted by default...]";
return str.c_str();
}
} // namespace Telephony
} // namespace OHOS

View File

@ -14,7 +14,6 @@
import("//build/ohos.gni") import("//build/ohos.gni")
RIL_ADAPTER = "../../" RIL_ADAPTER = "../../"
RIL_FRAMEWORKS = "../../frameworks/src"
config("hril_config") { config("hril_config") {
include_dirs = [ "$RIL_ADAPTER/interfaces/innerkits/include" ] include_dirs = [ "$RIL_ADAPTER/interfaces/innerkits/include" ]
@ -35,13 +34,6 @@ config("hril_config") {
} }
ohos_shared_library("hril_innerkits") { ohos_shared_library("hril_innerkits") {
all_dependent_configs = [
":hril_config",
"$RIL_ADAPTER/utils:utils_config",
]
sources = [ "$RIL_FRAMEWORKS/hril_base_parcel.cpp" ]
public_configs = [ public_configs = [
":hril_config", ":hril_config",
"$RIL_ADAPTER/utils:utils_config", "$RIL_ADAPTER/utils:utils_config",
@ -57,7 +49,7 @@ ohos_shared_library("hril_innerkits") {
"hilog:libhilog", "hilog:libhilog",
] ]
relative_install_dir = "chipset-pub-sdk" install_images = [ chipset_base_dir ]
part_name = "ril_adapter" part_name = "ril_adapter"
subsystem_name = "telephony" subsystem_name = "telephony"

View File

@ -1,219 +0,0 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_RIL_BASE_PARCEL_H
#define OHOS_RIL_BASE_PARCEL_H
#include <cassert>
#include "desensitize_string_stream.h"
#include "parcel.h"
#include "hril_types.h"
#include "telephony_log_wrapper.h"
namespace OHOS {
namespace Telephony {
// Serialize the underlying set of handler functions.
namespace BaseParcel {
// Read specific data from the parcel object.
bool Read(Parcel &parcel, int8_t &value);
bool Read(Parcel &parcel, uint8_t &value);
bool Read(Parcel &parcel, int32_t &value);
bool Read(Parcel &parcel, uint32_t &value);
bool Read(Parcel &parcel, int64_t &value);
bool Read(Parcel &parcel, uint64_t &value);
bool Read(Parcel &parcel, bool &value);
bool Read(Parcel &parcel, std::string &value);
// Reads only 32 bits of data. Such as: enum.
template<typename E>
bool Read(Parcel &parcel, E &e)
{
static_assert(sizeof(E) == sizeof(int32_t) && !std::is_pointer<E>::value,
"This interface is an enum-specific interface,"
" please use the enumeration type(type size == sizeof(int32_t)).");
return Read(parcel, *((int32_t *)&e));
}
// Write the data to the parcel object.
bool Write(Parcel &parcel, const int8_t &value);
bool Write(Parcel &parcel, const uint8_t &value);
bool Write(Parcel &parcel, const int32_t &value);
bool Write(Parcel &parcel, const uint32_t &value);
bool Write(Parcel &parcel, const int64_t &value);
bool Write(Parcel &parcel, const uint64_t &value);
bool Write(Parcel &parcel, const bool &value);
bool Write(Parcel &parcel, const std::string &value);
// Writes only 32 bits of data. Such as: enum.
template<typename E>
bool Write(Parcel &parcel, E &&e)
{
static_assert(sizeof(E) == sizeof(int32_t) && !std::is_pointer<E>::value,
"This interface is an enum-specific interface,"
" please use the enumeration type(type size == sizeof(int32_t)).");
return Write(parcel, *((const int32_t *)&e));
}
/**
* @brief Write the data set from Parcel.
* @tparam ValueTypes ValueTypes Support data types: uint8_t, int32_t, int64_t, bool, std::string.
* @param parcel Serialized data structure.
* @param vals Output data set.
* 1st param: slotId
* 2nd param: serialId
* @return true success
* @return false failed
*/
template<typename... ValueTypes>
bool WriteVals(Parcel &parcel, ValueTypes &&...vals)
{
// Write data with the return value "and".
return (Write(parcel, std::forward<ValueTypes>(vals)) && ...);
}
/**
* @brief Read the data set from Parcel
* @tparam ValueTypes Support data types: uint8_t, int32_t, int64_t, bool, std::string
* @param parcel Serialized data structure
* @param vals Outgoing data reference
* @return true success
* @return false failed
*/
template<typename... ValueTypes>
bool ReadVals(Parcel &parcel, ValueTypes &&...vals)
{
// Read data with the return value "and".
return (Read(parcel, std::forward<ValueTypes>(vals)) && ...);
}
} // namespace BaseParcel
class HrilBaseParcel : public virtual Parcelable {
public:
// Formatted output for serialized structures.
virtual const char *ToString() const;
protected:
virtual bool ReadBaseUint8(Parcel &parcel, uint8_t &value);
virtual bool ReadBaseInt32(Parcel &parcel, int32_t &value);
virtual bool ReadBaseInt64(Parcel &parcel, int64_t &value);
virtual bool ReadBaseBool(Parcel &parcel, bool &value);
virtual bool ReadBaseString(Parcel &parcel, std::string &value);
virtual bool WriteBaseUint8(Parcel &parcel, uint8_t value) const;
virtual bool WriteBaseInt32(Parcel &parcel, int32_t value) const;
virtual bool WriteBaseInt64(Parcel &parcel, int64_t value) const;
virtual bool WriteBaseBool(Parcel &parcel, bool value) const;
virtual bool WriteBaseString(Parcel &parcel, std::string value) const;
template<typename... ValueTypes>
bool Read(Parcel &parcel, ValueTypes &&...vals)
{
return BaseParcel::ReadVals(parcel, std::forward<ValueTypes>(vals)...);
}
template<typename... ValueTypes>
bool Write(Parcel &parcel, ValueTypes &&...vals) const
{
return BaseParcel::WriteVals(parcel, std::forward<ValueTypes>(vals)...);
}
// String streams: thread variables. Used to optimize execution efficiency.
std::stringstream &StringStream(void) const;
// String: Thread variable. Used to optimize execution efficiency.
std::string &String(void) const;
};
// Empty serialization class.
struct HrilEmptyParcel : public HrilBaseParcel {
bool ReadFromParcel(Parcel &parcel)
{
return true;
}
virtual bool Marshalling(Parcel &parcel) const override
{
return true;
}
std::shared_ptr<HrilEmptyParcel> UnMarshalling(Parcel &parcel)
{
return std::shared_ptr<HrilEmptyParcel>(nullptr);
}
void Dump(std::string, int32_t) {}
};
// Primitive type serialization class.
template<typename T>
struct HRilCommonParcel : public HrilBaseParcel {
T data;
HRilCommonParcel() {}
// copy constructor
HRilCommonParcel(const T &d) : data(d) {}
HRilCommonParcel(const T &&d) : data(d) {}
// Only the std::string template type is supported.
HRilCommonParcel(const char *s)
{
if (s != nullptr) {
data = s;
}
}
// The std::string template type is not supported.
HRilCommonParcel(const uint8_t *buf, size_t bufLen)
{
static_assert(std::is_class<T>::value == 0,
"This constructor does not support the std::string type,"
" please use the HRilStringParcel(const std::string &) constructor.");
assert((bufLen % sizeof(T)) == 0);
if (buf != nullptr) {
data = *(T *)buf;
} else {
data = 0;
}
}
HRilCommonParcel &operator=(const T &t)
{
data = t;
return *this;
}
bool ReadFromParcel(Parcel &parcel)
{
return Read(parcel, data);
}
virtual bool Marshalling(Parcel &parcel) const override
{
return Write(parcel, data);
}
std::shared_ptr<HRilCommonParcel<T>> UnMarshalling(Parcel &parcel)
{
return std::make_shared<HRilCommonParcel<T>>();
}
void Dump(std::string, int32_t) {}
virtual const char *ToString() const override
{
DesensitizeStringStream dss(String(), StringStream());
dss << DSS::Dese << data;
return *dss;
}
};
// Basic type serialization type extension.
using HRilUint8Parcel = struct HRilCommonParcel<uint8_t>;
using HRilInt32Parcel = struct HRilCommonParcel<int32_t>;
using HRilInt64Parcel = struct HRilCommonParcel<int64_t>;
using HRilBoolParcel = struct HRilCommonParcel<bool>;
using HRilStringParcel = struct HRilCommonParcel<std::string>;
static constexpr int32_t TELEPHONY_PARCEL_MAX_COUNT = 1024;
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_RIL_BASE_PARCEL_H

View File

@ -1,310 +0,0 @@
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_RIL_CALL_PARCEL_H
#define OHOS_RIL_CALL_PARCEL_H
#include "hril_base_parcel.h"
namespace OHOS {
namespace Telephony {
/**
* @brief Defines the dial information in 3GPP TS 27.007 V4.3.0 (2001-12) 7.7,
* AT + ATD
*/
struct DialInfo {
/** Request serial number. */
int32_t serial = 0;
/**
* Type of address octet in integer format (refer TS 24.008 [8]
* subclauses 10.5.4.7); default 145 when dialling string includes
* international access code character "+", otherwise 129.
*/
std::string address = "";
/**
* Calling Line Identification Restriction. From TS 27.007 V3.4.0
* (2000-03).
*/
int32_t clir = 0;
};
/**
* @brief Defines the call status information in 3GPP TS 27.007 V4.3.0
* (2001-12) AT+CGDCONT.
*/
struct CallInfo {
/**
* Call identification number as described in 3GPP TS 22.030 [19]
* sub-clause 6.5.5.1. This number can be used in +CHLD command operations.
*/
int32_t index = 0;
/** Call direction. The value 0 indicates the calling party, and the value
* 1 indicates the called party. */
int32_t dir = 0;
/**
* Indicates the call state:
* 0: activated state
* 1: call hold state
* 2: calling party, dialing state
* 3: calling party, ringback tone state
* 4: called party, incoming call state
* 5: called party, call waiting state
* 6: disconnected state
* 7: disconnecting state
* 8: idle state
*/
int32_t state = 0;
/**
* Indicates the call mode:
* 0: voice call
* 1: data call
* 2: fax
*/
int32_t mode = 0;
/**
* Indicates the Multi-party call status:
* 0: not a multi-party(conference) call
* 1: a multi-party(conference) call
*/
int32_t mpty = 0;
/**
* Indicates the call domain of the voice call:
* 0: CS domain
* 1: IP multimedia system (IMS) domain
*/
int32_t voiceDomain = 0;
/**
* Indicates the call type:
* 0: Voice call
* 1: Video call: send one-way video, two-way voice
* 2: Video call: one-way receiving video, two-way voice
* 3: Video call: two-way video, two-way voice
*/
int32_t callType = 0;
/** phone number in format specified by <type> */
std::string number = "";
/**
* Type of address octet in integer format (refer TS 24.008 [8]
* subclauses 10.5.4.7); default 145 when dialling string includes
* international access code character "+", otherwise 129. See 3GPP
* TS 27.007 V4.3.0 (2001-12) 6.1.
*/
int32_t type = 0;
/**
* Alphanumeric representation of <number> corresponding to the entry found
* in phonebook; used character set should be the one selected with command
* select TE character set +CSCS.
*/
std::string alpha = "";
};
/**
* @brief Defines the call status information list.
*/
struct CallInfoList {
/** The size of CallInfoList. */
int32_t callSize = 0;
/** The ID of the call status information list. */
int32_t flag = 0;
/** Call status information list. */
std::vector<CallInfo> calls {};
};
/**
* @brief Defines the emergency information.
*/
struct EmergencyInfo {
/** Number index. */
int32_t index = 0;
/** Total number of numbers. */
int32_t total = 0;
/** Emergency call number in string format. */
std::string eccNum = "";
/**
* Emergency call type:
* 0: Interface message of initiating an emergency call
* 1: Bandit police
* 2: Rescue
* 4: Fire alarm
* 8: Marine Police
* 16: Alpine rescue
*/
int32_t category = 0;
/**
* Whether the number is valid with or without a card:
* 0: valid without card
* 1: Valid with card
*/
int32_t simpresent = 0;
/** Mobile country code. */
std::string mcc = "";
/**
* Distinguishes CS domain abnormal service status:
* 0: all States are valid
* 1: the CS domain is not in normal service
*/
int32_t abnormalService = 0;
};
/**
* @brief Defines the emergency info list.
*/
struct EmergencyInfoList {
/** The size of the emergency info list. */
int32_t callSize = 0;
/** The ID of emergency info list. */
int32_t flag = 0;
/** Emergency info list. */
std::vector<EmergencyInfo> calls {};
};
/**
* @brief Defines the call forwarding information.
*/
struct CallForwardSetInfo {
/** Request serial number. */
int32_t serial = 0;
/**
* Call forwarding type:
* 0: call forwarding unconditional
* 1: call forwarding on busy
* 2: call forwarding on no reply
* 3: call forwarding not reachable (no network service, or power-off)
* 4: any call forwarding
* 5: any call forwarding conditional
*/
int32_t reason = 0;
/**
* Call forwarding operation mode:
* 0: deactivation
* 1: activation
* 2: status query
* 3: registration
* 4: deletion
*/
int32_t mode = 0;
/** Phone number. */
std::string number = "";
/** Service class. For details, see 3GPP TS 27.007. */
int32_t classx = 0;
};
/**
* @brief Defines the Unstructured Supplementary Data Service (USSD)
* information.
*/
struct UssdNoticeInfo {
/**
* Integer value.
* 0: The network does not require a TE reply (USSD-Notify initiated by the
* network or TE. The network does not need further information after
* starting operation);
* 1: The network needs a TE reply (USSD-Request initiated by the network,
* or TE sent After starting the operation, the network needs further
* information);
* 2: The USSD session is released by the network;
* 3: Other local clients have responded;
* 4: The operation is not supported;
* 5: The network timed out.
*/
int32_t m = 0;
/** USSD string, the maximum length is 160 characters. */
std::string str = "";
};
/**
* @brief Defines the supplementary service information.
*/
struct SsNoticeInfo {
/**
* Service type:
* 0: call forwarding unconditional
* 1: call forwarding on busy
* 2: call forwarding on no reply
* 3: call forwarding not reachable (no network service, or power-off)
*/
int32_t serviceType = 0;
/**
* Request type:
* 0: deactivation
* 1: activated
* 2: status query
* 3: registration
* 4: deletion
*/
int32_t requestType = 0;
/** Service class. For details, see 3GPP TS 27.007. */
int32_t serviceClass = 0;
/** Query result. For details, see {@link RilErrType}. */
int32_t result = 0;
};
/**
* @brief Active reporting of SRVCC status is controlled by the +CIREP command.
*
* This command complies with the 3GPP TS 27.007 protocol.
*/
struct SrvccStatus {
/**
* SRVCC status.
* 1: SRVCC starts;
* 2: SRVCC is successful;
* 3: SRVCC is cancelled;
* 4: SRVCC failed.
*/
int32_t status = 1;
};
/**
* @brief ringback voice event reported by the modem during dialing.
*
* Modem private commands, not a reported field specified by the 3gpp
* protocol.
*/
struct RingbackVoice {
/** 0 network alerting; 1 local alerting */
int32_t status = 0;
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_RIL_CALL_PARCEL_H

View File

@ -1,368 +0,0 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_RIL_DATA_PARCEL_H
#define OHOS_RIL_DATA_PARCEL_H
#include "hril_base_parcel.h"
namespace OHOS {
namespace Telephony {
/**
* @brief Defines the data service activation result.
*/
struct SetupDataCallResultInfo {
/** Activation result ID. */
int32_t flag = 0;
/** Data call fail reason, success is 0. */
int32_t reason = 0;
/** If errorCode != 0, suggested retry time. */
int32_t retryTime = 0;
/**
* From 3GPP TS 27.007 V17.3.0 (2021-09), specifies a particular PDP
* context definition. The parameter is local to the TE-MT interface and is
* used in other PDP context-related commands.
*/
int32_t cid = 0;
/**
* From 3GPP TS 27.007 V17.3.0 (2021-09), indicates the state of PDP
* context activation.
* 0: deactivated
* 1: activated
*/
int32_t active = 0;
/**
* PDP_type values from 3GPP TS 27.007 V17.3.0 (2021-09)
* Specifies the type of packet data protocol. The default value is
* manufacturer specific.
*/
std::string type = "";
/** Network interface name. */
std::string netPortName = "";
/**
* From 3GPP TS 27.007 V17.3.0 (2021-09)
* <local_addr and subnet_mask>: string type;
* shows the IP address and subnet mask of the MT. The string is given as
* dot-separated numeric (0-255) parameters on the form:
* 1. "a1.a2.a3.a4.m1.m2.m3.m4" for IPv4 or
* 2. "a1.a2.a3.a4.a5.a6.a7.a8.a9.a10.a11.a12.a13.a14.a15.a16.
* m1.m2.m3.m4.m5.m6.m7.m8.m9.m10.m11.m12.m13.m14.m15.m16" for IPv6.
* When +CGPIAF is supported, its settings can influence the format of this
* parameter returned with the execute form of +CGCONTRDP
*/
std::string address = "";
/**
* If the MT indicates more than two IP addresses of P-CSCF servers string
* type; shows the IP address of the secondary DNS server.When +CGPIAF is
* supported, its settings can influence the format of this parameter
* returned with the execute form of +CGCONTRDP.
*/
std::string dns = "";
/**
* From 3GPP TS 27.007 10.1.23 V4.3.0 (2001-12)
* string type; shows the IP address of the secondary DNS server.When
* +CGPIAF is supported, its settings can influence the format of this
* parameter returned with the execute form of +CGCONTRDP.
*/
std::string dnsSec = "";
/** Network gateway address. */
std::string gateway = "";
/**
* Maximum Transfer Unit. The range of permitted values (minimum value = 1
* or if the initial PDP context is supported minimum value = 0) is
* returned by the test form of the command.
*/
int32_t maxTransferUnit = 0;
/**
* From 3GPP TS 27.007 10.1.23 V4.3.0 (2001-12)
* string type; shows the IP address of the primary P-CSCF server.When
* +CGPIAF is supported, its settings can influence the format of this
* parameter returned with the execute form of +CGCONTRDP.
*/
std::string pCscfPrimAddr = "";
/**
* From 3GPP TS 27.007 10.1.23 V4.3.0 (2001-12)
* string type; shows the IP address of the secondary P-CSCF server. When
* +CGPIAF is supported, its settings can influence the format of this
* parameter returned with the execute form of +CGCONTRDP.
*/
std::string pCscfSecAddr = "";
/**
* From 3GPP TS 27.007 10.1.23 V4.3.0 (2001-12)
* integer type; identifies the PDU session, see 3GPP TS 24.501 [161].
*/
int32_t pduSessionId = 0;
};
/**
* @brief Defines the list of data service activation results.
*/
struct DataCallResultList {
/** Size of DataCall List */
size_t size = 0;
/** DataCall List. */
std::vector<SetupDataCallResultInfo> dcList {};
};
/**
* @brief Defines PDP context information in 3GPP TS 27.007 10.1 V4.3.0
* (2001-12)
*/
struct DataProfileDataInfo {
/** Request serial number. */
int32_t serial = 0;
/** Id of data profiles. */
int32_t profileId = 0;
/** Access Point Name. */
std::string apn = "";
/**
* (Packet Data Protocol type) a string parameter which specifies the type
* of packet data protocol.
*/
std::string protocol = "";
/** Roaming protocol version. */
std::string roamingProtocol = "";
/** APN verification type. */
int32_t verType = 0;
/** Indicates the username of pdp profile. */
std::string userName = "";
/** Indicates the password of pdp profile. */
std::string password = "";
};
/**
* @brief Defines the PDP context list.
*/
struct DataProfilesInfo {
/** Request serial number. */
int32_t serial = 0;
/** Number of PDP contexts. */
int32_t profilesSize = 0;
/** PDP context list. */
std::vector<DataProfileDataInfo> profiles {};
/** Roaming or not. */
bool isRoaming = false;
};
/**
* @brief Defines the data service information.
*/
struct DataCallInfo {
/** Request serial number. */
int32_t serial = 0;
/** Voice radio technology. */
int32_t radioTechnology = 0;
/** PDP context information. */
DataProfileDataInfo dataProfileInfo;
/**
* Whether the PDP context is set for the modem. The value true indicates
* that PDP context is set for the modem, and the value false indicates the
* opposite.
*/
bool modemCognitive = false;
/**
* Whether roaming is allowed. The value true indicates that roaming is
* allowed, and the value false indicates the opposite.
*/
bool roamingAllowed = false;
/**
* Whether the user is roaming. The value true indicates that the user is
* roaming, and the value false indicates the opposite.
*/
bool isRoaming = false;
};
/**
* @brief Defines the network bandwidth information.
*/
struct DataLinkBandwidthInfo {
/** Request serial number. */
int32_t serial = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* integer type; specifies a particular QoS flow definition, Traffic Flows
* definition and a PDP Context definition (see the +CGDCONT and +CGDSCONT
* commands).
*/
int32_t cid = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* 0, 5QI is selected by network
* [1 - 4]: value range for guaranteed bit rate QoS flows
* 65, 66, 67: values for guaranteed bit rate QoS flows
* [71 - 76]: value range for guaranteed bit rate QoS flows
* [5 - 9]: value range for non-guaranteed bit rate QoS flows
* 69, 70, 79, 80: values for non-guaranteed bit rate QoS flows
* [82 - 85]: value range for delay critical guaranteed bit rate QoS flows
* [128 - 254]: value range for Operator-specific 5QIs
*/
int32_t qi = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* integer type; indicates DL GFBR in case of GBR 5QI. The value is in
* kbit/s. This parameter is omitted for a non-GBR 5QI (see 3GPP TS 24.501
* [161]).
*/
int32_t dlGfbr = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* integer type; indicates UL GFBR in case of GBR 5QI. The value is in
* kbit/s. This parameter is omitted for a non-GBR 5QI (see 3GPP TS 24.501
* [161]).
*/
int32_t ulGfbr = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* integer type; indicates DL MFBR in case of GBR 5QI. The value is in
* kbit/s. This parameter is omitted for a non-GBR 5QI (see 3GPP TS 24.501
* [161]).
*/
int32_t dlMfbr = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* integer type; indicates UL MFBR in case of GBR 5QI. The value is in
* kbit/s. This parameter is omitted for a non-GBR 5QI (see 3GPP TS 24.501
* [161]).
*/
int32_t ulMfbr = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* integer type; indicates the UL session AMBR(see 3GPP TS 24.501 [161]).
* The value is in kbit/s.
*/
int32_t ulSambr = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* integer type; indicates the DL session AMBR(see 3GPP TS 24.501 [161]).
* The value is in kbit/s.
*/
int32_t dlSambr = 0;
/**
* From 3GPP TS 27.007 10.1.50 V4.3.0 (2021-10)
* integer type; indicates the averaging window(see 3GPP TS 24.501 [161]).
* The value is in milliseconds.
*/
int32_t averagingWindow = 0;
};
/**
* @brief Defines the network bandwidth reporting rule.
*/
struct DataLinkBandwidthReportingRule {
/** Request serial number. */
int32_t serial = 0;
/** Radio access technology. */
int32_t rat = 0;
/** Delay time. */
int32_t delayMs = 0;
/** Uplink delay. */
int32_t delayUplinkKbps = 0;
/** Downlink delay. */
int32_t delayDownlinkKbps = 0;
/** Maximum number of uplink parameters. */
int32_t maximumUplinkKbpsSize = 0;
/** Maximum number of downlink parameters. */
int32_t maximumDownlinkKbpsSize = 0;
/** Maximum uplink parameter list. */
std::vector<int32_t> maximumUplinkKbps {};
/** Maximum downlink parameter list. */
std::vector<int32_t> maximumDownlinkKbps {};
};
/**
* @brief Defines the data service performance mode.
*/
struct DataPerformanceInfo {
/** Data Performance Enable. eg: 1-enable, 0-disable */
int32_t performanceEnable = 0;
/** Whether Enforce Data Performance. eg: 1-enable, 0-disable */
int32_t enforce = 0;
};
/**
* @brief Defines the sleep mode for data services.
*/
struct DataSleepInfo {
/** Sleep Mode Enable. eg: 1-enable, 0-disable */
int32_t sleepEnable = 0;
};
/**
* @brief Defines the data link capability.
*/
struct DataLinkCapability {
/** Primary downlink capability in kbps. */
int32_t primaryDownlinkKbps;
/** Primary uplink capability in kbps. */
int32_t primaryUplinkKbps;
/** Secondary downlink capability in kbps. */
int32_t secondaryDownlinkKbps;
/** Secondary uplink capability in kbps. */
int32_t secondaryUplinkKbps;
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_RIL_DATA_PARCEL_H

View File

@ -1,86 +0,0 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_RIL_MODEM_PARCEL_H
#define OHOS_RIL_MODEM_PARCEL_H
#include "hril_base_parcel.h"
namespace OHOS {
namespace Telephony {
/**
* @brief Defines the common information.
*/
struct UniInfo {
/** Request serial number. */
int32_t serial = 0;
/** Index of Global System for Mobile Communications. */
int32_t gsmIndex = 0;
/** Common information ID. */
bool flag = false;
/** Parameter 1. */
int32_t arg1 = 0;
/** Parameter 2. */
int32_t arg2 = 0;
/** Temporary string. */
std::string strTmp = "";
};
/**
* @brief Defines the radio access technology of the CS domain.
*/
struct VoiceRadioTechnology {
/** System service status. */
HRilSrvStatus srvStatus = HRilSrvStatus::HRIL_NO_SRV_SERVICE;
/** System service domain. */
HRilSrvDomain srvDomain = HRilSrvDomain::HRIL_NO_DOMAIN_SERVICE;
/** Roaming status. */
HRilRoamStatus roamStatus = HRilRoamStatus::HRIL_ROAM_UNKNOWN;
/** Sim card status. */
HRilSimStatus simStatus = HRilSimStatus::HRIL_USIM_INVALID;
/** Sim card lock status. */
HRilSimLockStatus lockStatus = HRilSimLockStatus::HRIL_SIM_CARD_UNLOCK;
/** System mode. */
HRilSysMode sysMode = HRilSysMode::HRIL_NO_SYSMODE_SERVICE;
/** String corresponding to the system mode. */
std::string sysModeName = "";
/** Radio access technology type. For details, see {@link RilRadioTech}. */
HRilRadioTech actType = HRilRadioTech::RADIO_TECHNOLOGY_UNKNOWN;
/** String corresponding to the radio access technology type. */
std::string actName = "";
/** Radio access technology ID. */
int64_t flag = 0;
VoiceRadioTechnology() = default;
VoiceRadioTechnology(const HRilVoiceRadioInfo &hrilVoiceRadioInfo);
VoiceRadioTechnology &operator=(const HRilVoiceRadioInfo &hrilVoiceRadioInfo);
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_RIL_COMMON_PARCEL_H

View File

@ -1,754 +0,0 @@
/*
* Copyright (C) 2021-2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_RIL_NETWORK_PARCEL_H
#define OHOS_RIL_NETWORK_PARCEL_H
#include "hril_base_parcel.h"
namespace OHOS {
namespace Telephony {
/**
* @brief Defines the carrier information.
*/
struct OperatorInfoResult {
/** Long carrier name of the registered network. */
std::string longName = "";
/** Short carrier name of the registered network. */
std::string shortName = "";
/** MCC+MNC of the registered network. */
std::string numeric = "";
/** flag, Used by search network manager in response. */
int64_t flag = 0;
};
/**
* @brief Defines the available network information.
*/
struct AvailableNetworkInfo {
/** Long name of the registered network in alphanumeric format. */
std::string longName = "";
/** Short name of the registered network in alphanumeric format. */
std::string shortName = "";
/** Available network ID(MCC+MNC). */
std::string numeric = "";
/** Network status. For details, see {@link RilRegStatus}. */
int32_t status = 0;
/** Radio access technology type. For details, see {@link RilRadioTech}. */
int32_t rat = 0;
};
/**
* @brief Defines the available network list.
*/
struct AvailableNetworkList {
/** The size of available network list. */
int32_t itemNum = 0;
/** Available network list. */
std::vector<AvailableNetworkInfo> availableNetworkInfo {};
/** Network list flag */
int64_t flag = 0;
};
/**
* @brief Defines the network mode information.
*/
struct SetNetworkModeInfo {
/** Network mode. For details, see {@link PreferredNetworkTypeInfo}. */
int32_t selectMode = 0;
/** Operator information */
std::string oper = "";
/** flag, Used by search network manager in response. */
int64_t flag = 0;
};
/**
* @brief Voice registration status results
*/
struct CsRegStatusInfo {
/** The notifyType,Indicate the content of the notification. */
int32_t notifyType = 0;
/**
* The corresponding valid registration states are
* NOT_REG_MT_NOT_SEARCHING_OP, "REG_MT_HOME, NOT_REG_MT_SEARCHING_OP,
* REG_DENIED, UNKNOWN, REG_ROAMING".
*/
HRilRegStatus regStatus =
HRilRegStatus::NO_REG_MT_NO_SEARCH;
/** Location area code. */
int32_t lacCode = 0;
/** Cell ID. */
int32_t cellId = 0;
/** Available voice radio technology, RMS defined by radio technology. */
HRilRadioTech radioTechnology =
HRilRadioTech::RADIO_TECHNOLOGY_UNKNOWN;
/** flag, Used by search network manager in response. */
int64_t flag = 0;
};
/**
* @brief Defines the registration status information of the PS domain.
*/
struct PsRegStatusResultInfo {
/** The notifyType,Indicate the content of the notification. */
int32_t notifyType = 0;
/**
* Valid when are is ITE UNKNOWN REG = REG, otherwise it defined in
* RegStatus.
*/
HRilRegStatus regStatus = HRilRegStatus::NO_REG_MT_NO_SEARCH;
/** Location area code. */
int32_t lacCode = 0;
/** Cell ID. */
int32_t cellId = 0;
/** Radio access technology type. For details, see {@link RilRadioTech}. */
HRilRadioTech radioTechnology = HRilRadioTech::RADIO_TECHNOLOGY_UNKNOWN;
/** Whether the NR mode is available.*/
bool isNrAvailable = false;
/** Whether ENDC is available. */
bool isEnDcAvailable = false;
/** Whether DCNR is restricted. */
bool isDcNrRestricted = false;
/** flag, Used by search network manager in response. */
int64_t flag = 0;
};
/**
* @brief Defines the physical channel configuration.
*/
struct PhysicalChannelConfig {
/** Connection status. */
HRilCellConnectionStatus cellConnStatus = HRilCellConnectionStatus::HRIL_SERVING_CELL_UNKNOWN;
/** Radio access technology type. For details, see {@link RilRadioTech}. */
HRilRadioTech ratType = HRilRadioTech::RADIO_TECHNOLOGY_UNKNOWN;
/** Downlink bandwidth in kHz. */
int32_t cellBandwidthDownlinkKhz = 0;
/** Uplink bandwidth in kHz. */
int32_t cellBandwidthUplinkKhz = 0;
/** Frequency range. */
int32_t freqRange = 0;
/** Downlink channel ID. */
int32_t downlinkChannelNum = 0;
/** Uplink channel ID. */
int32_t uplinkChannelNum = 0;
/** Physical cell ID. */
int32_t physicalCellId = 0;
/** Logical device ID. */
int32_t contextIdNum = 0;
/**
* A list of data calls mapped to this physical channel. An empty list
* means the physical channel has no data call mapped to it.
*/
std::vector<int32_t> contextIds {};
};
/**
* @brief Defines the channel configuration information list.
*/
struct ChannelConfigInfoList {
/** The size of ChannelConfigInfoList. */
int32_t itemNum = 0;
/** Physical channel configuration list. */
std::vector<PhysicalChannelConfig> channelConfigInfos {};
/** flag, Used by search network manager in response */
int64_t flag = 0;
};
/**
* @brief Defines the GSM cellular information.
*/
typedef struct {
/** value:0~3 0:GSM850 1:GSM900 0:GSM1800 0:GSM1900 */
int32_t band;
/** Absolute Radio Frequency Channel Number of the BCCH carrier 0~1023 */
int32_t arfcn;
/** cell sit code 0~63 */
int32_t bsic;
/** Cell ID. */
int32_t cellId;
/** Location area code, which ranges from 0 to 0xFFFF. */
int32_t lac;
/** Signal received strength, which ranges from -120 to 37. */
int32_t rxlev;
/** Signal received quality, which ranges from 0 to 7. */
int32_t rxQuality;
/** Timing advance, which ranges from 0 to 63. */
int32_t ta;
} CellRatGsm;
/**
* @brief Defines the LTE cellular information.
*/
typedef struct {
/** Absolute Radio Frequency Channel Number of the BCCH carrier 0~1023 */
int32_t arfcn;
/** Cell ID. */
int32_t cellId;
/** Physical cell ID. */
int32_t pci;
/** Tracking Area Code 0~FFFF */
int32_t tac;
/** Reference Signal Received Power -140~-44, dBm */
int32_t rsrp;
/** Reference Signal Received Quality -19.5~-3 */
int32_t rsrq;
/** Receiving signal strength in dbm 90~-25 */
int32_t rssi;
} CellRatLte;
/**
* @brief Defines the WCDMA cellular information.
*/
typedef struct {
/** Absolute Radio Frequency Channel Number of the BCCH carrier 0~1023 */
int32_t arfcn;
/** Primary Scrambling Code. 0~511 */
int32_t psc;
/** Cell ID. */
int32_t cellId;
/** Tracking Area Code 0~FFFF. */
int32_t lac;
/** Reference Signal Received Power -140~-44, dBm */
int32_t rscp;
/** Reference Signal Received Quality -19.5~-3 */
int32_t rxlev;
/** Receiving signal strength in dbm 90~-25 */
int32_t ecno;
/** Discontinuous reception cycle length. 6~9 */
int32_t drx;
/** UTRAN Registration Area Identity. 0~65535 */
int32_t ura;
} CellRatWcdma;
/**
* @brief Defines the CDMA cellular information.
*/
typedef struct {
/** integer type and range is 0-65535 */
int32_t systemId;
/** integer type and range is 0-65535 */
int32_t networkId;
/** integer type and range is 0-65535 */
int32_t baseId;
/** integer type and range is 0-65535 */
int32_t zoneId;
/** integer type and range is 0-65535 */
int32_t pilotPn;
/** integer type and range is 0-65535 */
int32_t pilotStrength;
/** integer type and range is 0-65535 */
int32_t channel;
/** integer type and range is -648000 -- 648000, unit: second */
int32_t longitude;
/** integer type and range is -648000 -- 648000, unit: second */
int32_t latitude;
} CellRatCdma;
/**
* @brief Defines the TD-SCDMA cellular information.
*/
typedef struct {
/** Absolute RF channel number of the BCCH carrier. */
int32_t arfcn;
/** Synchronization flag. */
int32_t syncId;
/** Super cell. */
int32_t sc;
/** Cell ID. */
int32_t cellId;
/** Location area code. */
int32_t lac;
/** Received signal code power. */
int32_t rscp;
/** Discontinuous reception cycle. */
int32_t drx;
/** Routing area code. */
int32_t rac;
/** Super cell ID. */
int32_t cpid;
} CellRatTdscdma;
/**
* @brief Defines the NR cellular information.
*/
typedef struct {
/** Absolute RF channel number of the BCCH carrier. */
int32_t nrArfcn;
/** Physical cell ID. */
int32_t pci;
/** Tracking Area Code, which ranges from 0 to FFFF. */
int32_t tac;
/** NR cell ID. */
int64_t nci;
} CellRatNr;
/**
* @brief Defines the current cell information.
*/
struct CurrentCellInfo {
/** Radio access technology type. */
int32_t ratType = 0;
/** Mobile country code (MCC). */
int32_t mcc = 0;
/** Mobile network code (MNC). */
int32_t mnc = 0;
/** Cell information parameters. */
union {
CellRatGsm gsm;
CellRatLte lte;
CellRatWcdma wcdma;
CellRatCdma cdma;
CellRatTdscdma tdscdma;
CellRatNr nr;
} ServiceCellParas;
};
/**
* @brief Defines the current cell information list.
*/
struct CellListCurrentInfo {
/** The size of current cell information list. */
int32_t itemNum = 0;
/** Current cell information. */
std::vector<CurrentCellInfo> cellCurrentInfo {};
};
/**
* @brief Defines the NR cellular information.
*/
typedef struct {
/** Absolute RF channel number of the BCCH carrier. */
int32_t nrArfcn;
/** Physical cell ID. */
int32_t pci;
/** Tracking Area Code, which ranges from 0 to FFFF. */
int32_t tac;
/** NR cell ID. */
int64_t nci;
/** Reference Signal Received Power. */
int32_t rsrp;
/** Reference Signal Received Quality. */
int32_t rsrq;
} CellRatNrExt;
/**
* @brief Defines the current cell information.
*/
struct CurrentCellInformation {
/** Radio access technology type. */
int32_t ratType = 0;
/** Mobile country code (MCC). */
int32_t mcc = 0;
/** Mobile network code (MNC). */
int32_t mnc = 0;
/** Cell information parameters. */
union {
CellRatGsm gsm;
CellRatLte lte;
CellRatWcdma wcdma;
CellRatCdma cdma;
CellRatTdscdma tdscdma;
CellRatNrExt nr;
} ServiceCellParas;
};
/**
* @brief Defines the current cell information list.
*/
struct CellListCurrentInformation {
/** The size of current cell information list. */
int32_t itemNum = 0;
/** Current cell information. */
std::vector<CurrentCellInformation> cellCurrentInfo {};
};
/**
* @brief Defines the GSM cell information.
*/
typedef struct {
/** value:0~3 0:GSM850 1:GSM900 0:GSM1800 0:GSM1900 */
int32_t band;
/** Absolute Radio Frequency Channel Number of the BCCHcarrier 0~1023 */
int32_t arfcn;
/** cell sit code 0~63 */
int32_t bsic;
/** Cell information ID */
int32_t cellId;
/** Location area code 0~FFFF */
int32_t lac;
/** <RXLEV> dbm -120~37 */
int32_t rxlev;
} CellListRatGsm;
/**
* @brief Defines the LTE cell information.
*/
typedef struct {
/** Absolute Radio FreListquency Channel Number of the BCCHcarrier 0~1023
*/
int32_t arfcn;
/** Physical cell ID. */
int32_t pci;
/** Reference Signal Received Power -140~-44, dBm */
int32_t rsrp;
/** Reference Signal Received Quality -19.5~-3 */
int32_t rsrq;
/** <RXLEV> dbm -120~37 */
int32_t rxlev;
} CellListRatLte;
/**
* @brief Defines the WCDMA cell information.
*/
typedef struct {
/** Absolute Radio Frequency Channel Number of the BCCHcarrier 0~16383 */
int32_t arfcn;
/** Primary Scrambling Code. 0~511 */
int32_t psc;
/** Received Signal Code Power in dBm -120~25, dBm */
int32_t rscp;
/** The ratio of power per modulation bit to noise spectral density. -25~0
*/
int32_t ecno;
} CellListRatWcdma;
/**
* @brief Defines the CDMA cell information.
*/
typedef struct {
/** integer type and range is 0-65535 */
int32_t systemId;
/** integer type and range is 0-65535 */
int32_t networkId;
/** integer type and range is 0-65535 */
int32_t baseId;
/** integer type and range is 0-65535 */
int32_t zoneId;
/** integer type and range is 0-65535 */
int32_t pilotPn;
/** integer type and range is 0-65535 */
int32_t pilotStrength;
/** integer type and range is 0-65535 */
int32_t channel;
/** integer type and range is -648000 -- 648000, unit: second */
int32_t longitude;
/** integer type and range is -648000 -- 648000, unit: second */
int32_t latitude;
} CellListRatCdma;
/**
* @brief Defines the TD-SCDMA cell information.
*/
typedef struct {
/** Absolute RF channel number of the BCCH carrier. */
int32_t arfcn;
/** Synchronization flag. */
int32_t syncId;
/** Super cell. */
int32_t sc;
/** Cell ID. */
int32_t cellId;
/** Location area code, which ranges from 0 to 0xFFFF. */
int32_t lac;
/** Received signal code power. */
int32_t rscp;
/** Discontinuous reception cycle. */
int32_t drx;
/** Routing area code. */
int32_t rac;
/** 8-bit Cell Parameters ID described in TS 25.331, 0..127, INT_MAX if
* unknown */
int32_t cpid;
} CellListRatTdscdma;
/**
* @brief Defines the NR cell information.
*/
typedef struct {
/** Absolute RF channel number of the BCCH carrier. */
int32_t nrArfcn;
/** Physical cell ID. */
int32_t pci;
/** Tracking Area Code, which ranges from 0 to FFFF. */
int32_t tac;
/** NR cell ID. */
int64_t nci;
} CellListRatNr;
/**
* @brief Defines the neighboring cell information.
*/
struct CellNearbyInfo {
/**
* Access technology type:
* 0: unknown
* 1: GSM
* 2: CDMA
* 3: WCDMA
* 4: TD-SCDMA
* 5: LTE
* 6: NR
*/
int32_t ratType = 0;
/** Cell information for different network modes. */
union {
CellListRatGsm gsm;
CellListRatLte lte;
CellListRatWcdma wcdma;
CellListRatCdma cdma;
CellListRatTdscdma tdscdma;
CellListRatNr nr;
} ServiceCellParas;
};
/**
* @brief Defines the neighboring cell list.
*/
struct CellListNearbyInfo {
/** The size of nearby info of cell list. */
int32_t itemNum = 0;
/** Neighboring cell list. */
std::vector<CellNearbyInfo> cellNearbyInfo {};
};
/**
* @brief Defines the preferred network type.
*/
struct PreferredNetworkTypeInfo {
/**
* Network type
* 0: automatic
* 1: GSM
* 2: WCDMA.
* 3: LTE.
* 4: LTE and WCDMA
* 5: LTE, WCDMA, and GSM
* 6: WCDMA and GSM
* 7: CDMA
* 8: EV-DO
* 9: EV-DO and CDMA
* 10: WCDMA, GSM, EV-DO, and CDMA
* 11: LTE, EV-DO, and CDMA
* 12: LTE, WCDMA, GSM, EV-DO, and CDMA
* 13: TD-SCDMA
* 14: TD-SCDMA and GSM
* 15: TD-SCDMA and WCDMA
* 16: TD-SCDMA, WCDMA, and GSM
* 17: LTE and TD-SCDMA
* 18: LTE, TDSCDMA, and GSM
* 19: LTE, TD-SCDMA, and WCDMA
* 20: LTE, TDSCDMA, WCDMA, and GSM
* 21: TD-SCDMA, WCDMA, GSM, EV-DO, and CDMA
* 22: LTE, TD-SCDMA, WCDMA, GSM, EV-DO, and CDMA
* 31: NR
* 32: NR and LTE
* 33: NR, LTE, and WCDMA
* 34: NR, LTE, WCDMA, and GSM
* 35: NR, LTE, EV-DO, and CDMA
* 36: NR, LTE, WCDMA, GSM, EV-DO, and CDMA
* 37: NR, LTE, and TD-SCDMA.
* 38: NR, LTE, TDSCDMA, and GSM
* 39: NR, LTE, TD-SCDMA, and WCDMA
* 40: NR, LTE, TD-SCDMA, WCDMA, and GSM
* 41: NR, LTE, TD-SCDMA, WCDMA, GSM, EV-DO, and CDMA
*/
int32_t preferredNetworkType = 0;
/** Network ID */
int64_t flag = 0;
};
struct NrModeInfo {
int32_t nrMode = 0;
int64_t flag = 0;
};
struct SsbIdInfo {
/** SSB index. */
int32_t ssbId;
/** Reference Signal Received Power -140~-44, dBm */
int32_t rsrp;
};
struct NeighboringCellSsbInfo {
/** Physical cell ID. */
int32_t pci;
/** Absolute Radio Frequency Channel Number of the BCCH carrier 0~1023 */
int32_t arfcn;
/** Reference Signal Received Power -140~-44, dBm */
int32_t rsrp;
/** Signal To Interference Plus Noise Ratio. */
int32_t sinr;
/** Neighboring cell ssbId list, always size is 4 */
std::vector<SsbIdInfo> ssbIdList;
};
struct NrCellSsbIds {
/** Absolute Radio Frequency Channel Number of the BCCH carrier 0~1023 */
int32_t arfcn;
/** cid */
int64_t cid;
/** pic */
int32_t pic;
/** Reference Signal Received Power -140~-44, dBm */
int32_t rsrp;
/** Signal To Interference Plus Noise Ratio. */
int32_t sinr;
/** Time advance. */
int32_t timeAdvance;
/** Service cell ssbId list, always size is 8 */
std::vector<SsbIdInfo> sCellSsbList;
/** Neighboring cell ssb list count, mas size is 4 */
int32_t nbCellCount;
/** Neighboring cell ssb info list, mas size is 4 */
std::vector<NeighboringCellSsbInfo> nbCellSsbList;
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_RIL_NETWORK_PARCEL_H

View File

@ -1,353 +0,0 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_RIL_SIM_PARCEL_H
#define OHOS_RIL_SIM_PARCEL_H
#include "hril_base_parcel.h"
namespace OHOS {
namespace Telephony {
/**
* @brief Defines the SIM card status information.
*/
struct CardStatusInfo {
/** SIM card index. */
int32_t index = 0;
/**
* SIM card type:
* 0: unknown.
* 1: common SIM card.
* 2: USIM, supporting 4G.
*/
int32_t simType = 0;
/**
* SIM card status:
* 1: unknown
* 0: SIM card not inserted
* 1: SIM card detected normally
* 2: PIN required
* 3: PUK required
* 4: PIN2 required
* 5: PUK2 required
*/
int32_t simState = 0;
};
/**
* @brief Defines the SIM data request information in 3GPP TS 27.007 V4.3.0
* (2001-12) 8.18, + CRSM.
*/
struct SimIoRequestInfo {
/** Command passed on by the ME to the SIM; refer GSM 51.011 [28] */
int32_t command = 0;
/**
* This is the identifier of an elementary datafile on SIM.
* Mandatory for every command except STATUS
*/
int32_t fileId = 0;
/**
* Parameters passed on by the MT to the SIM.
* These parameters are mandatory for every command,
* except GET RESPONSE and STATUS.
* The values are described in 3GPP TS 51.011 [28]
*/
int32_t p1 = 0;
int32_t p2 = 0;
int32_t p3 = 0;
/**
* Information which shall be written to the SIM(hexadecimal character
* format; refer +CSCS).
*/
std::string data = "";
/**
* Contains the path of an elementary file on the SIM/UICC in hexadecimal
* format as defined in ETSI TS 102 221 [60] (e.g. "7F205F70" in SIM and
* UICC case). The <pathid> shall only be used in the mode "select by path
* from MF" as defined in ETSI TS 102 221 [60].
*/
std::string path = "";
/** Request serial number. */
int32_t serial = 0;
/** PIN2 */
std::string pin2 = "";
/** App ID. */
std::string aid = "";
};
/**
* @brief Defines the response to the SIM data request in 3GPP TS 27.007 V4.3.0
* (2001-12) 8.18, + CRSM.
*/
struct IccIoResultInfo {
/**
* Information from the SIM about the execution of the actual command.
* These parameters are delivered to the TE in both cases, on successful or
* failed execution of the command
*/
int32_t sw1 = 0;
int32_t sw2 = 0;
/** Response information */
std::string response = "";
};
/**
* @brief Defines the SIM card lock information.
*/
struct SimLockInfo {
/** Request serial number. */
int32_t serial = 0;
/**
* String type, which specifies the object operated by this command.
* "SC": SIM PIN1;
* "AO": prohibit all outgoing calls;
* "OI": All international outgoing calls are prohibited;
* "OX": All international outgoing calls are prohibited, except for the country of origin;
* "AI": All incoming calls are prohibited;
* "IR": When roaming outside the home area, all incoming calls are prohibited;
* "AB": prohibit all services (applicable only when <mode>=0);
* "AG": Outgoing call is prohibited (applicable only when <mode>=0);
* "AC": Incoming calls are prohibited (applicable only when <mode>=0);
* "FD": FDN;
* "PN": lock the network;
* "PU": lock subnet;
* "PP": Lock SP.
*/
std::string fac = "";
/**
* Mode:
* 0: deactivation (When fac is set to PN, PU, or PP, the operation is equivalent to unlocking.)
* 1: activation (When fac is set to PN, PU, or PP, activation is not supported.)
* 2: query
*/
int32_t mode = 0;
/**
* SIM card lock status.
* It indicates the activation status of the first three layers of locks when fac is set to PN, PU, or PP.
* 0: not activated
* 1: activated
*/
int32_t status = 0;
/** Password text */
std::string passwd = "";
/**
* Service type. The value is the sum of integers that represent the service type. The default value is 255.
* 1: telephony service
* 2: data service
* 4: fax service
* 8: SMS service
* 16: data circuit sync
* 32: data circuit async
* 64: dedicated packet access
* 128: dedicated portable device (PAD) access
*/
int32_t classx = 0;
};
/**
* @brief Defines the SIM card password information.
*/
struct SimPasswordInfo {
/** Request serial number. */
int32_t serial = 0;
/**
* String type, which specifies the object operated by this command.
* SCSIM PIN1
* P2SIM PIN2
* "OI": All international outgoing calls are prohibited;
* "OX": All international outgoing calls are prohibited, except for the country of origin;
* "AI": All incoming calls are prohibited;
* "IR": When roaming outside the home area, all incoming calls are prohibited;
* "AB": prohibit all services (applicable only when <mode>=0);
* "AG": Outgoing call is prohibited (applicable only when <mode>=0);
* "AC": Incoming call service is prohibited (applicable only when <mode>=0).
*/
std::string fac = "";
/** Old password text */
std::string oldPassword = "";
/** New password text */
std::string newPassword = "";
/** Max length of oldPassword or newPassword */
int32_t passwordLength = 0;
};
/**
* @brief Defines the maximum number of SIM password attempts.
*/
struct SimPinInputTimes {
/** Request serial number. */
int32_t serial = 0;
/**
* Param of string.
* SIM PIN2 is mean that SIM PIN2 request. SIM PUK2 is mean that SIM PUK2
* request.
*/
std::string code = "";
/**
* The remaining number of entries, for PIN2, the maximum number of entries is 3 times;
* for PUK2, the maximum number of entries is 10 times.
*/
int32_t times = 0;
/**
* The remaining number of PUK, the maximum number of entries is 10 times.
*/
int32_t pukTimes = 0;
/**
* The remaining number of PIN, the maximum number of entries is 3 times.
*/
int32_t pinTimes = 0;
/**
* The remaining number of PUK2, the maximum number of entries is 10
* times.
*/
int32_t puk2Times = 0;
/**
* The remaining number of PIN2, the maximum number of entries is 3 times.
*/
int32_t pin2Times = 0;
};
/**
* @brief Defines the APDU data transmission request information.
*/
struct ApduSimIORequestInfo {
/** Request serial number. */
int32_t serial = 0;
/** Channel ID */
int32_t channelId = 0;
/** APDU instruction type. For details, see ETSI 102 221 [55]. */
int32_t type = 0;
/** APDU instruction. For details, see ETSI 102 221 [55]. */
int32_t instruction = 0;
/**
* Command parameter 1 of the SIM data request. For details, see 3GPP
* TS 51.011[28].
*/
int32_t p1 = 0;
/**
* Command parameter 2 of the SIM data request. For details, see 3GPP
* TS 51.011[28].
*/
int32_t p2 = 0;
/**
* Command parameter 3 of the SIM data request. For details, see 3GPP
* TS 51.011[28]. If p3 is a negative value, a 4-byte APDU is sent to the
* SIM card.
*/
int32_t p3 = 0;
/** Data to be transmitted */
std::string data = "";
};
/**
* @brief Defines the SIM card authentication request information.
*/
struct SimAuthenticationRequestInfo {
/** Request serial number. */
int32_t serial = 0;
/** App ID */
std::string aid = "";
/** Authentication data */
std::string authData = "";
};
/**
* @brief Defines the Send SIM matched operator info request information.
*/
struct NcfgOperatorInfo {
/** Operator Name Matched with SIM card */
std::string operName = "";
/** Operator Key Matched with SIM card */
std::string operKey = "";
/** Current SIM State */
int32_t state = 0;
/** Reserved Field */
std::string reserve = "";
};
/**
* @brief Defines the response to the request for enabling the logical channel of the APDU.
*/
struct OpenLogicalChannelResponse {
/**
* Information from the SIM about the execution of the actual command.
* These parameters are delivered to the TE in both cases, on successful or
* failed execution of the command
*/
int32_t sw1 = 0;
/**
* Status word 2 of the SIM card, which is returned by the SIM card after
* command execution.
*/
int32_t sw2 = 0;
/** ID of the opened logical channel */
int32_t channelId = 0;
/** Response information */
std::string response = "";
};
/**
* @brief Defines the response to the request for unlocking the SIM card.
*/
struct LockStatusResp {
/** Query result. For details, see {@link RilErrType}. */
int32_t result = 0;
/** Number of remaining attempts */
int32_t remain = 0;
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_RIL_SIM_PARCEL_H

View File

@ -1,294 +0,0 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OHOS_RIL_SMS_PARCEL_H
#define OHOS_RIL_SMS_PARCEL_H
#include "hril_base_parcel.h"
namespace OHOS {
namespace Telephony {
/**
* @brief Defines a GSM SMS message.
*/
struct GsmSmsMessageInfo {
/** Request serial number. */
int32_t serial = 0;
/** Short Message Service Center Protocol Data Unit see GSM 03.40 */
std::string smscPdu = "";
/** Protocol Data Unit */
std::string pdu = "";
/** GSM SMS Status. */
int32_t state = 0;
};
/**
* @brief Defines a CDMA SMS message.
*/
struct SendCdmaSmsMessageInfo {
/** Request serial number. */
int32_t serial = 0;
/** Short Message Service Center Protocol Data Unit see GSM 03.40 */
std::string smscPdu = "";
/** CDMA SMS Status. */
int32_t state = 0;
};
/**
* @brief Defines the SMS message information in a SIM card.
*/
struct SmsMessageIOInfo {
/** Request serial number. */
int32_t serial = 0;
/** Short Message Service Center Protocol Data Unit see GSM 03.40. */
std::string smscPdu = "";
/** Protocol Data Unit */
std::string pdu = "";
/** The status of SMS message information in a SIM card. */
int32_t state = 0;
/** Message index. */
int32_t index = 0;
};
/**
* @brief Defines the SMSC address information.
*/
struct ServiceCenterAddress {
/** Request serial number. */
int32_t serial = 0;
/** SMSC address type. For details, see 3GPP TS 24.011 [6]. */
int32_t tosca = 0;
/** Protocol Data Unit */
std::string address = "";
};
/**
* @brief Defines the GSM cell broadcast configuration information in 3GPP
* TS 27.005 AT+CSCB = [<mode>[,<mids>[,<dcss>]]].
*/
struct CBConfigInfo {
/** Request serial number. */
int32_t serial = 0;
/** Mode (activated or not). */
int32_t mode = 0;
/**
* Response type:
* 0: query and report
* 1: report
*/
int32_t indicationType = 0;
/** Message IDs. */
std::string mids = "";
/** Data coding schemes. */
std::string dcss = "";
};
/**
* @brief Defines the CDMA cell broadcast configuration information.
*/
struct CdmaCBConfigInfo {
/** Service. */
int32_t service = 0;
/** Language. */
int32_t language = 0;
/** Selected or not. */
int32_t checked = 0;
};
/**
* @brief Defines the CDMA cell broadcast configuration information list.
*/
struct CdmaCBConfigInfoList {
/** Request serial number. */
int32_t serial = 0;
/** The size of CB config information list. */
int32_t size = 0;
/** CB config information list. */
std::vector<CdmaCBConfigInfo> list {};
};
/**
* @brief Defines the cell broadcast report information.
*
* From 3GPP TS 27.005 if text mode (+CMGF=1):
* <CR><LF>+CBM:
* <sn>,<mid>,<dcs>,<page>,<pages><CR><LF><data><CR>
* <LF> if PDU mode
* (+CMGF=0):
* <CR><LF>+CBM: <length><CR><LF><pdu><CR><LF>
*/
struct CBConfigReportInfo {
/**
* Response type:
* 0: query and report
* 1: report
*/
int32_t indicationType = 0;
/** Cell broadcast SN */
int32_t sn = 0;
/** Message IDs */
int32_t mid = 0;
/** Cell broadcast page number. */
int32_t page = 0;
/** Total number of cell broadcast pages. */
int32_t pages = 0;
/** Data coding schemes. */
std::string dcs = "";
/** Decoded cell broadcast content. */
std::string data = "";
/** Number of PDU bytes. */
int32_t length = 0;
/** Protocol data unit. */
std::string pdu = "";
};
/**
* @brief Defines the SMS message information.
*/
struct SmsMessageInfo {
/**
* Response type:
* 0: query and report
* 1: report
*/
int32_t indicationType = 0;
/** Total number. */
int32_t size = 0;
/** Protocol data unit. */
std::vector<uint8_t> pdu {};
};
/**
* @brief Defines the processing mode of received SMS messages.
*/
struct ModeData {
/** Request serial number. */
int32_t serial = 0;
/** Whether to receive SMS messages */
bool result = false;
/**
* Processing mode of received SMS messages. For details, see {@link
* AckIncomeCause}.
*/
int32_t mode = 0;
/** Protocol Data Unit. */
std::string pdu = "";
};
/**
* @brief Defines an SMS message response.
*/
struct SendSmsResultInfo {
/**
* TP-Message-Reference for GSM, and BearerData MessageId for CDMA
* from 3GPP2 C.S0015-B, v2.0, 4.5-1
*/
int32_t msgRef = 0;
/** Protocol Data Unit */
std::string pdu = "";
/** Error code */
int32_t errCode = 0;
/** SMS message response ID */
int64_t flag = 0;
};
struct CdmaSmsAddress {
int32_t digitMode = 0;
int32_t mode = 0;
int32_t type = 0;
int32_t plan = 0;
unsigned char number = 0;
unsigned char bytes[36] = { 0 };
};
struct CdmaSmsSubAddress {
int32_t type = 0;
unsigned char odd = 0;
unsigned char number = 0;
unsigned char bytes[36] = { 0 };
};
struct CdmaSmsMessageInfo {
int32_t serial = 0;
int32_t serviceId = 0;
unsigned char isExist = 0;
int32_t type = 0;
CdmaSmsAddress address;
CdmaSmsSubAddress subAddress;
int32_t size = 0;
unsigned char bytes[255] = { 0 };
};
struct CdmaSmsInfo {
/**
* Response type:
* 0: query and report
* 1: report
*/
int32_t indicationType = 0;
/**
* TP-Message-Reference for GSM, and BearerData MessageId for CDMA
* from 3GPP2 C.S0015-B, v2.0, 4.5-1
*/
int32_t msgRef = 0;
/** Protocol Data Unit. */
std::string pdu = "";
/**
* If unknown or not applicable, that is -1 from 3GPP 27.005, 3.2.5 for
* GSM/UMTS, 3GPP2 N.S0005 (IS-41C) Table 171 for CDMA
*/
int32_t errCode = 0;
};
} // namespace Telephony
} // namespace OHOS
#endif // OHOS_RIL_SMS_PARCEL_H

View File

@ -17,7 +17,7 @@
#define OHOS_HRIL_CALL_H #define OHOS_HRIL_CALL_H
#include "hril_base.h" #include "hril_base.h"
#include "hril_call_parcel.h" // #include "hril_call_parcel.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {

View File

@ -17,8 +17,8 @@
#define OHOS_HRIL_DATA_H #define OHOS_HRIL_DATA_H
#include "hril_base.h" #include "hril_base.h"
#include "hril_data_parcel.h" // #include "hril_data_parcel.h"
#include "hril_modem_parcel.h" // #include "hril_modem_parcel.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {

View File

@ -17,7 +17,7 @@
#define OHOS_HRIL_MODEM_H #define OHOS_HRIL_MODEM_H
#include "hril_base.h" #include "hril_base.h"
#include "hril_modem_parcel.h" // #include "hril_modem_parcel.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {

View File

@ -17,7 +17,7 @@
#define OHOS_HRIL_NETWORK_H #define OHOS_HRIL_NETWORK_H
#include "hril_base.h" #include "hril_base.h"
#include "hril_network_parcel.h" // #include "hril_network_parcel.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {

View File

@ -17,7 +17,7 @@
#define OHOS_HRIL_SIM_H #define OHOS_HRIL_SIM_H
#include "hril_base.h" #include "hril_base.h"
#include "hril_sim_parcel.h" // #include "hril_sim_parcel.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {

View File

@ -17,7 +17,7 @@
#define OHOS_HRIL_SMS_H #define OHOS_HRIL_SMS_H
#include "hril_base.h" #include "hril_base.h"
#include "hril_sms_parcel.h" // #include "hril_sms_parcel.h"
namespace OHOS { namespace OHOS {
namespace Telephony { namespace Telephony {

View File

@ -15,7 +15,7 @@
#include "hril_call.h" #include "hril_call.h"
#include "hril_call_parcel.h" // #include "hril_call_parcel.h"
#include "hril_notification.h" #include "hril_notification.h"
#include "hril_request.h" #include "hril_request.h"

View File

@ -29,7 +29,10 @@ ohos_shared_library("hril_hdf") {
configs = [ "$RIL_ADAPTER/utils:utils_config" ] configs = [ "$RIL_ADAPTER/utils:utils_config" ]
deps = [ "$RIL_ADAPTER/services/hril:hril" ] deps = [
"$RIL_ADAPTER/services/hril:hril",
"$RIL_ADAPTER/interfaces/innerkits:hril_innerkits",
]
external_deps = [ external_deps = [
"hdf_core:libhdf_host", "hdf_core:libhdf_host",

View File

@ -41,6 +41,7 @@ ohos_unittest("tel_ril_adapter_gtest") {
deps = [ deps = [
"$SOURCE_DIR/services/hril:hril", "$SOURCE_DIR/services/hril:hril",
"$SOURCE_DIR/services/hril_hdf:hril_hdf", "$SOURCE_DIR/services/hril_hdf:hril_hdf",
"$SOURCE_DIR/interfaces/innerkits:hril_innerkits",
] ]
defines = [ defines = [
"TELEPHONY_LOG_TAG = \"RilAdapterGtest\"", "TELEPHONY_LOG_TAG = \"RilAdapterGtest\"",

View File

@ -275,8 +275,6 @@ HWTEST_F(BranchTest, Telephony_HrilManager_Call_001, Function | MediumTest | Lev
HRilRegOps(nullptr); HRilRegOps(nullptr);
ReleaseRilAdapter(); ReleaseRilAdapter();
OnTimerCallback(nullptr, nullptr, nullptr); OnTimerCallback(nullptr, nullptr, nullptr);
VoiceRadioTechnology voiceRadioTechnology;
VoiceRadioTechnology test = voiceRadioTechnology;
EXPECT_EQ(manager->SendRilAck(), 0); EXPECT_EQ(manager->SendRilAck(), 0);
manager->hrilCall_.clear(); manager->hrilCall_.clear();
EXPECT_NE(manager->CloseUnFinishedUssd(0, 0), 0); EXPECT_NE(manager->CloseUnFinishedUssd(0, 0), 0);

View File

@ -1,86 +0,0 @@
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef DESENSITIZE_STRING_STREAM_H
#define DESENSITIZE_STRING_STREAM_H
#include <sstream>
namespace OHOS {
namespace Telephony {
namespace DSS {
// encrypt
inline void Dese() {}
}
/**
* @brief Desensitized string stream: used to desensitize fields and output them into strings.
* When a field needs to be desensitized, please output DSS::Dese before the field output,
* for example: dss << DSS::Dese << field1 << field2.
*/
class DesensitizeStringStream {
using dese = void(*)();
public:
DesensitizeStringStream() = delete;
DesensitizeStringStream(std::string &out, std::stringstream &ss, char separator = ',')
: separator_(separator), ss_(ss), out_(out)
{}
inline DesensitizeStringStream &operator<<(dese d)
{
desensitize_ = true;
return *this;
}
template<typename T>
inline DesensitizeStringStream &operator<<(T t)
{
if (desensitize_) {
operator()(t);
desensitize_ = false;
} else {
ss_ << t << separator_;
}
return *this;
}
inline const char* operator*() const
{
out_ = ss_.str();
return out_.c_str();
}
private:
/* Use bracket operators: desensitize specific fields. */
template<typename T>
inline void operator()(T &&t)
{
std::streampos s = ss_.tellp();
ss_ << t;
std::streampos e = ss_.tellp();
std::streampos dur = (e - s) / 2;
ss_.seekp(-dur, std::ios::end);
ss_ << std::string(dur, '*') << separator_ << "\0";
}
char separator_;
bool desensitize_ = false;
std::stringstream &ss_;
std::string &out_;
};
} // namespace Telephony
} // namespace OHOS
#endif // DESENSITIZE_STRING_STREAM_H