Fixed deprecated liblinphone APIs

This commit is contained in:
Sylvain Berfini 2019-05-06 11:45:19 +02:00
parent 8123c5dbeb
commit 3a2f54eece
11 changed files with 41 additions and 33 deletions

View file

@ -203,7 +203,7 @@ public class LinphoneManager implements SensorEventListener {
if ((state == State.IncomingReceived || state == State.IncomingEarlyMedia)
&& getCallGsmON()) {
if (mCore != null) {
mCore.declineCall(call, Reason.Busy);
call.decline(Reason.Busy);
}
} else if (state == State.IncomingReceived
&& (LinphonePreferences.instance().isAutoAnswerEnabled())
@ -241,7 +241,7 @@ public class LinphoneManager implements SensorEventListener {
&& !localVideo
&& !autoAcceptCameraPolicy
&& mCore.getConference() == null) {
mCore.deferCallUpdate(call);
call.deferUpdate();
}
}
}

View file

@ -851,7 +851,7 @@ public class CallActivity extends LinphoneGenericActivity
if (videoDisabled) {
CallParams params = core.createCallParams(call);
params.enableVideo(false);
core.updateCall(call, params);
call.update(params);
} else {
mVideoProgress.setVisibility(View.VISIBLE);
if (call.getRemoteParams() != null && !call.getRemoteParams().lowBandwidthEnabled()) {
@ -1000,14 +1000,14 @@ public class CallActivity extends LinphoneGenericActivity
private void pauseOrResumeCall(Call call) {
Core core = LinphoneManager.getCore();
if (call != null && core.getCurrentCall() == call) {
core.pauseCall(call);
call.pause();
if (isVideoEnabled(core.getCurrentCall())) {
mIsVideoCallPaused = true;
}
mPause.setSelected(true);
} else if (call != null) {
if (call.getState() == State.Paused) {
core.resumeCall(call);
call.resume();
if (mIsVideoCallPaused) {
mIsVideoCallPaused = false;
}
@ -1025,7 +1025,7 @@ public class CallActivity extends LinphoneGenericActivity
}
if (currentCall != null) {
core.terminateCall(currentCall);
currentCall.terminate();
} else if (core.isInConference()) {
core.terminateConference();
} else {
@ -1192,7 +1192,7 @@ public class CallActivity extends LinphoneGenericActivity
core.enableVideoDisplay(true);
}
core.acceptCallUpdate(call, params);
call.acceptUpdate(params);
}
private void hideStatusBar() {

View file

@ -190,7 +190,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (LinphoneService.isReady()
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
LinphoneManager.getCore().terminateCall(mCall);
mCall.terminate();
finish();
}
return super.onKeyDown(keyCode, event);
@ -214,7 +214,7 @@ public class CallIncomingActivity extends LinphoneGenericActivity {
}
mAlreadyAcceptedOrDeniedCall = true;
LinphoneManager.getCore().terminateCall(mCall);
mCall.terminate();
finish();
}

View file

@ -124,7 +124,7 @@ public class CallManager {
}
// Not yet in video call: try to re-invite with video
core.updateCall(call, params);
call.update(params);
return true;
}
@ -140,9 +140,7 @@ public class CallManager {
Log.e("[Call Manager] Trying to updateCall while not in call: doing nothing");
return;
}
CallParams params = core.createCallParams(call);
mBandwidthManager.updateWithProfileSettings(params);
core.updateCall(call, null);
call.update(null);
}
public void newOutgoingCall(AddressType address) {
@ -238,7 +236,7 @@ public class CallManager {
private void terminateCall() {
Core core = LinphoneManager.getCore();
if (core.inCall()) {
core.terminateCall(core.getCurrentCall());
core.getCurrentCall().terminate();
}
}
@ -268,7 +266,7 @@ public class CallManager {
return false;
}
core.acceptCallWithParams(call, params);
call.acceptWithParams(params);
return true;
}

View file

@ -217,7 +217,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (LinphoneService.isReady()
&& (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_HOME)) {
LinphoneManager.getCore().terminateCall(mCall);
mCall.terminate();
finish();
}
return super.onKeyDown(keyCode, event);
@ -238,7 +238,7 @@ public class CallOutgoingActivity extends LinphoneGenericActivity implements OnC
}
private void decline() {
LinphoneManager.getCore().terminateCall(mCall);
mCall.terminate();
finish();
}

View file

@ -79,7 +79,6 @@ import org.linphone.core.Content;
import org.linphone.core.Core;
import org.linphone.core.EventLog;
import org.linphone.core.Factory;
import org.linphone.core.LimeState;
import org.linphone.core.Participant;
import org.linphone.core.ParticipantDevice;
import org.linphone.core.Reason;
@ -1115,7 +1114,7 @@ public class ChatMessagesFragment extends Fragment
final Address from = msg.getFromAddress();
final LinphoneContact contact = ContactsManager.getInstance().findContactFromAddress(from);
if (LinphoneManager.getCore().limeEnabled() == LimeState.Mandatory) {
if (LinphoneManager.getCore().limeX3DhEnabled()) {
final Dialog dialog =
((ChatActivity) getActivity())
.displayDialog(

View file

@ -358,7 +358,7 @@ public class LinphoneContact extends AndroidContact
mFriend.done();
}
if (created) {
core.addFriend(mFriend);
core.getDefaultFriendList().addFriend(mFriend);
}
if (!ContactsManager.getInstance().hasReadContactsAccess()) {

View file

@ -177,18 +177,25 @@ public class HistoryDetailFragment extends Fragment {
private void displayHistory() {
if (mSipUri != null) {
Address lAddress = Factory.instance().createAddress(mSipUri);
Address address = Factory.instance().createAddress(mSipUri);
mChatSecured.setVisibility(View.GONE);
if (lAddress != null) {
CallLog[] logs = LinphoneManager.getCore().getCallHistoryForAddress(lAddress);
Core core = LinphoneManager.getCore();
if (address != null && core != null) {
ProxyConfig proxyConfig = core.getDefaultProxyConfig();
CallLog[] logs;
if (proxyConfig != null) {
logs = core.getCallHistory(address, proxyConfig.getIdentityAddress());
} else {
logs = core.getCallHistoryForAddress(address);
}
List<CallLog> logsList = Arrays.asList(logs);
mLogsList.setAdapter(
new HistoryLogAdapter(
getActivity(), R.layout.history_detail_cell, logsList));
mContactAddress.setText(LinphoneUtils.getDisplayableAddress(lAddress));
mContact = ContactsManager.getInstance().findContactFromAddress(lAddress);
mContactAddress.setText(LinphoneUtils.getDisplayableAddress(address));
mContact = ContactsManager.getInstance().findContactFromAddress(address);
if (mContact != null) {
mContactName.setText(mContact.getFullName());
@ -207,7 +214,7 @@ public class HistoryDetailFragment extends Fragment {
? LinphoneUtils.getAddressDisplayName(mSipUri)
: mDisplayName);
ContactAvatar.displayAvatar(
LinphoneUtils.getAddressDisplayName(lAddress), mAvatarLayout);
LinphoneUtils.getAddressDisplayName(address), mAvatarLayout);
mAddToContacts.setVisibility(View.VISIBLE);
mGoToContact.setVisibility(View.GONE);
}

View file

@ -636,7 +636,8 @@ public class AccountSettingsFragment extends SettingsFragment {
mUseAsDefault.setChecked(mProxyConfig.equals(core.getDefaultProxyConfig()));
mUseAsDefault.setEnabled(!mUseAsDefault.isChecked());
mOutboundProxy.setChecked(mProxyConfig.getRoute() != null);
String[] routes = mProxyConfig.getRoutes();
mOutboundProxy.setChecked(routes != null && routes.length > 0);
mIce.setChecked(natPolicy.iceEnabled());
mIce.setEnabled(

View file

@ -45,6 +45,7 @@ import org.linphone.core.Transports;
import org.linphone.core.Tunnel;
import org.linphone.core.TunnelConfig;
import org.linphone.core.VideoActivationPolicy;
import org.linphone.core.VideoDefinition;
import org.linphone.core.tools.Log;
import org.linphone.purchase.Purchasable;
import org.linphone.utils.LinphoneUtils;
@ -338,7 +339,9 @@ public class LinphonePreferences {
public void setPreferredVideoSize(String preferredVideoSize) {
if (getLc() == null) return;
getLc().setPreferredVideoSizeByName(preferredVideoSize);
VideoDefinition preferredVideoDefinition =
Factory.instance().createVideoDefinitionFromName(preferredVideoSize);
getLc().setPreferredVideoDefinition(preferredVideoDefinition);
}
public int getPreferredVideoFps() {
@ -719,24 +722,24 @@ public class LinphonePreferences {
public String getDefaultDisplayName() {
if (getLc() == null) return null;
return getLc().getPrimaryContactParsed().getDisplayName();
return getLc().createPrimaryContactParsed().getDisplayName();
}
public void setDefaultDisplayName(String displayName) {
if (getLc() == null) return;
Address primary = getLc().getPrimaryContactParsed();
Address primary = getLc().createPrimaryContactParsed();
primary.setDisplayName(displayName);
getLc().setPrimaryContact(primary.asString());
}
public String getDefaultUsername() {
if (getLc() == null) return null;
return getLc().getPrimaryContactParsed().getUsername();
return getLc().createPrimaryContactParsed().getUsername();
}
public void setDefaultUsername(String username) {
if (getLc() == null) return;
Address primary = getLc().getPrimaryContactParsed();
Address primary = getLc().createPrimaryContactParsed();
primary.setUsername(username);
getLc().setPrimaryContact(primary.asString());
}

View file

@ -59,7 +59,7 @@ public class CallButton extends ImageView implements OnClickListener, AddressAwa
if (core.getCurrentCall() == null) {
return;
}
core.transferCall(core.getCurrentCall(), mAddress.getText().toString());
core.getCurrentCall().transfer(mAddress.getText().toString());
} else {
LinphoneManager.getCallManager().newOutgoingCall(mAddress);
}