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) {
|
public void setHandsetMode(Boolean on) {
|
||||||
if (mLc.isIncomingInvitePending() && on) {
|
if (mLc.isIncomingInvitePending() && on) {
|
||||||
handsetON = true;
|
handsetON = true;
|
||||||
mLc.acceptCall(mLc.getCurrentCall());
|
acceptCall(mLc.getCurrentCall());
|
||||||
LinphoneActivity.instance().startIncallActivity();
|
LinphoneActivity.instance().startIncallActivity();
|
||||||
} else if (on && CallActivity.isInstanciated()) {
|
} else if (on && CallActivity.isInstanciated()) {
|
||||||
handsetON = true;
|
handsetON = true;
|
||||||
|
@ -1173,7 +1173,7 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
public void run() {
|
public void run() {
|
||||||
if (mLc != null) {
|
if (mLc != null) {
|
||||||
if (mLc.getCallsNb() > 0) {
|
if (mLc.getCallsNb() > 0) {
|
||||||
mLc.acceptCall(call);
|
acceptCall(call);
|
||||||
if (LinphoneManager.getInstance() != null) {
|
if (LinphoneManager.getInstance() != null) {
|
||||||
LinphoneManager.getInstance().routeAudioToReceiver();
|
LinphoneManager.getInstance().routeAudioToReceiver();
|
||||||
if (LinphoneActivity.instance() != null)
|
if (LinphoneActivity.instance() != null)
|
||||||
|
@ -1465,14 +1465,24 @@ public class LinphoneManager implements CoreListener, SensorEventListener, Accou
|
||||||
return reinviteWithVideo();
|
return reinviteWithVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean acceptCallIfIncomingPending() throws CoreException {
|
public boolean acceptCall(Call call) {
|
||||||
if (mLc.isIncomingInvitePending()) {
|
if (call == null) return false;
|
||||||
mLc.acceptCall(mLc.getCurrentCall());
|
|
||||||
return true;
|
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 false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return acceptCallWithParams(call, params);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean acceptCallWithParams(Call call, CallParams params) {
|
public boolean acceptCallWithParams(Call call, CallParams params) {
|
||||||
mLc.acceptCallWithParams(call, params);
|
mLc.acceptCallWithParams(call, params);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -246,17 +246,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
|
||||||
}
|
}
|
||||||
alreadyAcceptedOrDeniedCall = true;
|
alreadyAcceptedOrDeniedCall = true;
|
||||||
|
|
||||||
CallParams params = LinphoneManager.getLc().createCallParams(mCall);
|
if (!LinphoneManager.getInstance().acceptCall(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)) {
|
|
||||||
// the above method takes care of Samsung Galaxy S
|
// the above method takes care of Samsung Galaxy S
|
||||||
Toast.makeText(this, R.string.couldnt_accept_call, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, R.string.couldnt_accept_call, Toast.LENGTH_LONG).show();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -58,8 +58,6 @@ public class CallButton extends ImageView implements OnClickListener, AddressAwa
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
try {
|
|
||||||
if (!LinphoneManager.getInstance().acceptCallIfIncomingPending()) {
|
|
||||||
if (mAddress.getText().length() > 0) {
|
if (mAddress.getText().length() > 0) {
|
||||||
LinphoneManager.getInstance().newOutgoingCall(mAddress);
|
LinphoneManager.getInstance().newOutgoingCall(mAddress);
|
||||||
} else {
|
} else {
|
||||||
|
@ -87,11 +85,6 @@ public class CallButton extends ImageView implements OnClickListener, AddressAwa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (CoreException e) {
|
|
||||||
LinphoneManager.getInstance().terminateCall();
|
|
||||||
onWrongDestinationAddress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void onWrongDestinationAddress() {
|
protected void onWrongDestinationAddress() {
|
||||||
Toast.makeText(getContext()
|
Toast.makeText(getContext()
|
||||||
|
|
Loading…
Reference in a new issue