use of im.tny.segvault.s2ls.InNetworkState in project underlx by underlx.
the class MainService method checkStopForeground.
private boolean checkStopForeground(S2LS loc) {
if (loc.getCurrentTargetRoute() == null && !(loc.getState() instanceof InNetworkState)) {
SharedPreferences sharedPref = getSharedPreferences("settings", MODE_PRIVATE);
boolean permanentForeground = sharedPref.getBoolean(PreferenceNames.PermanentForeground, false);
if (permanentForeground) {
startPermanentForeground();
} else {
stopForeground(true);
}
return true;
}
return false;
}
use of im.tny.segvault.s2ls.InNetworkState in project underlx by underlx.
the class MainService method dumpDebugInfo.
// DEBUG:
public String dumpDebugInfo() {
String s = "Service created on " + creationDate.toString();
s += (wfc.isScanning() ? String.format(". WFC scanning every %d s", wfc.getScanInterval() / 1000) : ". WFC not scanning") + "\n";
for (Network n : getNetworks()) {
S2LS loc;
synchronized (lock) {
loc = locServices.get(n.getId());
}
s += "Network " + n.getNames("en")[0] + "\n";
s += "State machine: " + loc.getState().toString() + "\n";
s += String.format("\tIn network? %b\n\tNear network? %b\n", loc.inNetwork(), loc.nearNetwork());
if (loc.getState() instanceof InNetworkState) {
s += "\tPossible stops:\n";
for (Stop stop : loc.getLocation().vertexSet()) {
s += String.format("\t\t%s (%s)\n", stop.getStation().getName(), stop.getLine().getNames("en")[0]);
}
s += "\tPath:\n";
if (loc.getCurrentTrip() != null) {
for (Connection c : loc.getCurrentTrip().getEdgeList()) {
s += String.format("\t\t%s -> %s\n", c.getSource().toString(), c.getTarget().toString());
}
if (loc.getCurrentTargetRoute() != null) {
s += String.format("\t\tCurrent path complies? %b\n", loc.getCurrentTargetRoute().checkPathCompliance(loc.getCurrentTrip()));
}
}
}
}
try {
API.AuthTest authTest = API.getInstance().getAuthTest();
s += "API auth test result: " + authTest.result + "\n";
s += "API key as perceived by server: " + authTest.key + "\n";
} catch (APIException e) {
e.printStackTrace();
s += "Error testing API authentication\n";
}
synchronizer.attemptSync();
return s;
}
Aggregations