Clean acceptCall code and add recordFile in params before accepting a call
This commit is contained in:
parent
eb1a3f0e98
commit
90774931d7
3 changed files with 40 additions and 47 deletions
|
@ -795,7 +795,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
public void setHandsetMode(Boolean on) {
|
||||
if (mLc.isIncomingInvitePending() && on) {
|
||||
handsetON = true;
|
||||
mLc.acceptCall(mLc.getCurrentCall());
|
||||
acceptCall(mLc.getCurrentCall());
|
||||
LinphoneActivity.instance().startIncallActivity();
|
||||
} else if (on && CallActivity.isInstanciated()) {
|
||||
handsetON = true;
|
||||
|
@ -1173,7 +1173,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
public void run() {
|
||||
if (mLc != null) {
|
||||
if (mLc.getCallsNb() > 0) {
|
||||
mLc.acceptCall(call);
|
||||
acceptCall(call);
|
||||
if (LinphoneManager.getInstance() != null) {
|
||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||
if (LinphoneActivity.instance() != null)
|
||||
|
@ -1465,14 +1465,24 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
|||
return reinviteWithVideo();
|
||||
}
|
||||
|
||||
public boolean acceptCallIfIncomingPending() throws CoreException {
|
||||
if (mLc.isIncomingInvitePending()) {
|
||||
mLc.acceptCall(mLc.getCurrentCall());
|
||||
return true;
|
||||
}
|
||||
public boolean acceptCall(Call call) {
|
||||
if (call == null) return false;
|
||||
|
||||
CallParams params = LinphoneManager.getLc().createCallParams(call);
|
||||
|
||||
boolean isLowBandwidthConnection = !LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance().getApplicationContext());
|
||||
|
||||
if (params != null) {
|
||||
params.enableLowBandwidth(isLowBandwidthConnection);
|
||||
params.setRecordFile(LinphoneUtils.getCallRecordingFilename(getContext(), call.getRemoteAddress()));
|
||||
} else {
|
||||
Log.e("Could not create call params for call");
|
||||
return false;
|
||||
}
|
||||
|
||||
return acceptCallWithParams(call, params);
|
||||
}
|
||||
|
||||
public boolean acceptCallWithParams(Call call, CallParams params) {
|
||||
mLc.acceptCallWithParams(call, params);
|
||||
return true;
|
||||
|
|
|
@ -246,17 +246,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
|||
}
|
||||
alreadyAcceptedOrDeniedCall = true;
|
||||
|
||||
CallParams params = LinphoneManager.getLc().createCallParams(mCall);
|
||||
|
||||
boolean isLowBandwidthConnection = !LinphoneUtils.isHighBandwidthConnection(LinphoneService.instance().getApplicationContext());
|
||||
|
||||
if (params != null) {
|
||||
params.enableLowBandwidth(isLowBandwidthConnection);
|
||||
} else {
|
||||
Log.e("Could not create call params for call");
|
||||
}
|
||||
|
||||
if (params == null || !LinphoneManager.getInstance().acceptCallWithParams(mCall, params)) {
|
||||
if (!LinphoneManager.getInstance().acceptCall(mCall)) {
|
||||
// the above method takes care of Samsung Galaxy S
|
||||
Toast.makeText(this, R.string.couldnt_accept_call, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
|
|
|
@ -58,8 +58,6 @@ public class CallButton extends ImageView implements OnClickListener, AddressAwa
|
|||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
try {
|
||||
if (!LinphoneManager.getInstance().acceptCallIfIncomingPending()) {
|
||||
if (mAddress.getText().length() > 0) {
|
||||
LinphoneManager.getInstance().newOutgoingCall(mAddress);
|
||||
} else {
|
||||
|
@ -87,11 +85,6 @@ public class CallButton extends ImageView implements OnClickListener, AddressAwa
|
|||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
LinphoneManager.getInstance().terminateCall();
|
||||
onWrongDestinationAddress();
|
||||
}
|
||||
}
|
||||
|
||||
protected void onWrongDestinationAddress() {
|
||||
Toast.makeText(getContext()
|
||||
|
|
Loading…
Reference in a new issue