<info>
<process>foundation</process>
<systemability> <!-- Declare a system ability and its profile -->
<name>4005</name> <!-- Declare the id of system ability. Must be same with system_ability_definition.h -->
<libpath>libtel_call_manager.z.so</libpath>
<run-on-create>true</run-on-create> <!-- "true" means the system ability would start immediately, "false" means the system ability would start on demand. -->
<distributed>false</distributed> <!-- "true" means the system ability supports distributed scheduling while "false" is not. -->
<dump-level>1</dump-level> <!-- Declare the dump level. 1-high; 2-media; 3-low -->
</systemability>
</info>
```
if (callNumber.length() > ACCOUNT_NUMBER_MAX_LENGTH) {
TELEPHONY_LOGE("the account number length exceeds the limit");
return CALL_ERR_NUMBER_OUT_OF_RANGE;
}
result = DialCall(callNumber, dialInfo);//调用CallManagerService里的DialCall函数,CallManagerService是CallManagerServiceStub的子类
TELEPHONY_LOGI("result:%{public}d", result);
if (!reply.WriteInt32(result)) {
TELEPHONY_LOGE("fail to write parcel");
return TELEPHONY_ERR_WRITE_REPLY_FAIL;
}
return result;
}
```
```
class CellularCallService : public SystemAbility,
public CellularCallStub,//继承了CellularCallStub
public std::enable_shared_from_this<CellularCallService>
int32_t CSControl::Dial(const CellularCallInfo &callInfo)
{
TELEPHONY_LOGI("Dial start");
int32_t ret = DialPreJudgment(callInfo);
if (ret != TELEPHONY_SUCCESS) {
return ret;
}
ModuleServiceUtils moduleServiceUtils;
PhoneType netType = moduleServiceUtils.GetNetworkStatus(callInfo.slotId);
if (netType == PhoneType:HONE_TYPE_IS_GSM) {
return DialGsm(callInfo);//根据netType来决定调用GSM拨号,还是其它。我们以DialGsm来拉通流程
}
if (netType == PhoneType:HONE_TYPE_IS_CDMA) {
return DialCdma(callInfo);//调用Cdma拨号
}
TELEPHONY_LOGE("Dial return, net type error.");
return CALL_ERR_UNSUPPORTED_NETWORK_TYPE;
}
int32_t CSControl::DialGsm(const CellularCallInfo &callInfo)
{//
TELEPHONY_LOGI("DialGsm entry.");
StandardizeUtils standardizeUtils;
// Remove the phone number separator
std::string newPhoneNum = standardizeUtils.RemoveSeparatorsPhoneNumber(callInfo.phoneNum);
CLIRMode clirMode = CLIRMode::DEFAULT;
if (IsNeedExecuteMMI(callInfo.slotId, newPhoneNum, clirMode)) {
TELEPHONY_LOGI("DialGsm return, mmi code type.");
return RETURN_TYPE_MMI;
}
if (!CanCall(connectionMap_)) {
TELEPHONY_LOGE("DialGsm return, error type: call state error.");
return CALL_ERR_CALL_COUNTS_EXCEED_LIMIT;
}
// Calls can be put on hold, recovered, released, added to conversation,
// and transferred similarly as defined in 3GPP TS 22.030 [19].
if (IsInState(connectionMap_, TelCallState::CALL_STATUS_ACTIVE)) {
// New calls must be active, so other calls need to be hold
TELEPHONY_LOGI("DialGsm, GSM is have connection in active state.");
CellularCallConnectionCS pConnection;
// Delay dialing to prevent failure to add a new call while making a multi-party call
// Will it block the main thread or other threads? Will the reception of messages be blocked during sleep?
// - a call can be temporarily disconnected from the ME but the connection is retained by the network
pConnection.SwitchCallRequest(callInfo.slotId);
}
return EncapsulateDialCommon(callInfo.slotId, newPhoneNum, clirMode);//调用了CSControl::EncapsulateDialCommon
}
int32_t CSControl::EncapsulateDialCommon(int32_t slotId, const std::string &phoneNum, CLIRMode &clirMode)
{
DialRequestStruct dialRequest;
/**
* <idx>: integer type;
* call identification number as described in 3GPP TS 22.030 [19] subclause 4.5.5.1
* this number can be used in +CHLD command operations
* <dir>:
*/
dialRequest.phoneNum = phoneNum;
/**
* <n> (parameter sets the adjustment for outgoing calls):
* 0 presentation indicator is used according to the subscription of the CLIR service
* 1 CLIR invocation
* 2 CLIR suppression
*/
dialRequest.clirMode = clirMode;
/**
* An example of voice group call service request usage:
* ATD*17*753#500; (originate voice group call with the priority level 3)
* OK (voice group call setup was successful)
*/
CellularCallConnectionCS csConnection;
return csConnection.DialRequest(slotId, dialRequest);//调用了CellularCallConnectionCS下DialRequest函数
}
```
int32_t WriteATCommand(const char *s, int32_t isPdu, int32_t atFd)
{
TELEPHONY_LOGI("cmd:%{public}s", s);
ssize_t ret;
size_t i = 0;
size_t len = strlen(s);
if (atFd < 0) {
return AT_ERR_CHANNEL_CLOSED;
}
while (i < len) {
do {
//写数据到串口
ret = write(atFd, s + i, len - i);
} while (ret < 0 && errno == EINTR);
if (ret < 0) {
return AT_ERR_GENERIC;
}
i += ret;
}
if (isPdu != 0) {
do {
ret = write(atFd, "\x1A", 1);
} while ((ret < 0 && errno == EINTR) || (ret == 0));
} else {
do {
ret = write(atFd, "\r", 1);
} while ((ret < 0 && errno == EINTR) || (ret == 0));
}
if (ret < 0) {
return AT_ERR_GENERIC;
}
return VENDOR_SUCCESS;
}