Fix presence crash

This commit is contained in:
Sylvain Berfini 2014-01-30 16:57:59 +01:00
parent 10c4cdb902
commit 48143cdcfc
2 changed files with 22 additions and 8 deletions

View file

@ -262,6 +262,8 @@ public class InCallActivity extends FragmentActivity implements
speaker.setVisibility(View.VISIBLE); speaker.setVisibility(View.VISIBLE);
} catch (NullPointerException npe) { Log.e("Bluetooth: Audio routes menu disabled on tablets for now (3)"); } } catch (NullPointerException npe) { Log.e("Bluetooth: Audio routes menu disabled on tablets for now (3)"); }
} }
LinphoneManager.getInstance().changeStatusToOnThePhone();
} }
private void refreshInCallActions() { private void refreshInCallActions() {
@ -1172,6 +1174,8 @@ public class InCallActivity extends FragmentActivity implements
@Override @Override
protected void onDestroy() { protected void onDestroy() {
LinphoneManager.getInstance().changeStatusToOnline();
if (mControlsHandler != null && mControls != null) { if (mControlsHandler != null && mControls != null) {
mControlsHandler.removeCallbacks(mControls); mControlsHandler.removeCallbacks(mControls);
} }

View file

@ -353,24 +353,34 @@ public class LinphoneManager implements LinphoneCoreListener {
return instance; return instance;
} }
private boolean isPresenceModelActivitySet() {
return isInstanciated() && getLc().getPresenceModel() != null || getLc().getPresenceModel().getActivity() != null;
}
public void changeStatusToOnline() { 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); PresenceModel model = LinphoneCoreFactoryImpl.instance().createPresenceModel(PresenceActivityType.Online, null);
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceModel(model); getLc().setPresenceModel(model);
} }
} }
public void changeStatusToAway() { public void changeStatusToOnThePhone() {
if (LinphoneManager.isInstanciated()) { if (isInstanciated() && isPresenceModelActivitySet() && getLc().getPresenceModel().getActivity().getType() != PresenceActivityType.OnThePhone) {
PresenceModel model = LinphoneCoreFactoryImpl.instance().createPresenceModel(PresenceActivityType.Away, null); getLc().getPresenceModel().getActivity().setType(PresenceActivityType.OnThePhone);
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceModel(model); } else if (isInstanciated() && !isPresenceModelActivitySet()) {
PresenceModel model = LinphoneCoreFactoryImpl.instance().createPresenceModel(PresenceActivityType.OnThePhone, null);
getLc().setPresenceModel(model);
} }
} }
public void changeStatusToOffline() { 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); PresenceModel model = LinphoneCoreFactoryImpl.instance().createPresenceModel(PresenceActivityType.Offline, null);
LinphoneManager.getLcIfManagerNotDestroyedOrNull().setPresenceModel(model); getLc().setPresenceModel(model);
} }
} }