Fix presence crash
This commit is contained in:
parent
10c4cdb902
commit
48143cdcfc
2 changed files with 22 additions and 8 deletions
|
@ -262,6 +262,8 @@ public class InCallActivity extends FragmentActivity implements
|
|||
speaker.setVisibility(View.VISIBLE);
|
||||
} catch (NullPointerException npe) { Log.e("Bluetooth: Audio routes menu disabled on tablets for now (3)"); }
|
||||
}
|
||||
|
||||
LinphoneManager.getInstance().changeStatusToOnThePhone();
|
||||
}
|
||||
|
||||
private void refreshInCallActions() {
|
||||
|
@ -1172,6 +1174,8 @@ public class InCallActivity extends FragmentActivity implements
|
|||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
LinphoneManager.getInstance().changeStatusToOnline();
|
||||
|
||||
if (mControlsHandler != null && mControls != null) {
|
||||
mControlsHandler.removeCallbacks(mControls);
|
||||
}
|
||||
|
|
|
@ -352,25 +352,35 @@ public class LinphoneManager implements LinphoneCoreListener {
|
|||
|
||||
return instance;
|
||||
}
|
||||
|
||||
private boolean isPresenceModelActivitySet() {
|
||||
return isInstanciated() && getLc().getPresenceModel() != null || getLc().getPresenceModel().getActivity() != null;
|
||||
}
|
||||
|
||||
public void changeStatusToOnline() {
|
||||
if (LinphoneManager.isInstanciated()) {
|
||||
if (isInstanciated() && isPresenceModelActivitySet() && getLc().getPresenceModel().getActivity().getType() != PresenceActivityType.Online) {
|
||||
getLc().getPresenceModel().getActivity().setType(PresenceActivityType.Online);
|
||||
} else if (isInstanciated() && !isPresenceModelActivitySet()) {
|
||||
PresenceModel model = LinphoneCoreFactoryImpl.instance().createPresenceModel(PresenceActivityType.Online, null);
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceModel(model);
|
||||
getLc().setPresenceModel(model);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeStatusToAway() {
|
||||
if (LinphoneManager.isInstanciated()) {
|
||||
PresenceModel model = LinphoneCoreFactoryImpl.instance().createPresenceModel(PresenceActivityType.Away, null);
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceModel(model);
|
||||
public void changeStatusToOnThePhone() {
|
||||
if (isInstanciated() && isPresenceModelActivitySet() && getLc().getPresenceModel().getActivity().getType() != PresenceActivityType.OnThePhone) {
|
||||
getLc().getPresenceModel().getActivity().setType(PresenceActivityType.OnThePhone);
|
||||
} else if (isInstanciated() && !isPresenceModelActivitySet()) {
|
||||
PresenceModel model = LinphoneCoreFactoryImpl.instance().createPresenceModel(PresenceActivityType.OnThePhone, null);
|
||||
getLc().setPresenceModel(model);
|
||||
}
|
||||
}
|
||||
|
||||
public void changeStatusToOffline() {
|
||||
if (LinphoneManager.isInstanciated()) {
|
||||
if (isInstanciated() && isPresenceModelActivitySet() && getLc().getPresenceModel().getActivity().getType() != PresenceActivityType.Offline) {
|
||||
getLc().getPresenceModel().getActivity().setType(PresenceActivityType.Offline);
|
||||
} else if (isInstanciated() && !isPresenceModelActivitySet()) {
|
||||
PresenceModel model = LinphoneCoreFactoryImpl.instance().createPresenceModel(PresenceActivityType.Offline, null);
|
||||
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceModel(model);
|
||||
getLc().setPresenceModel(model);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue