Remove HTML entities from clock skew error, code style

This commit is contained in:
str4d
2015-06-15 11:32:19 +00:00
parent d6e79ed0a7
commit c541ae0347

View File

@ -49,7 +49,8 @@ public abstract class Util implements I2PConstants {
//System.err.println("APK Path" + ": " + _apkPath);
if (pi.versionName != null)
return pi.versionName;
} catch (Exception e) {}
} catch (Exception e) {
}
return "??";
}
@ -60,7 +61,7 @@ public abstract class Util implements I2PConstants {
*/
public static RouterContext getRouterContext() {
List<RouterContext> contexts = RouterContext.listContexts();
if ( !((contexts == null) || (contexts.isEmpty())) ) {
if (!((contexts == null) || (contexts.isEmpty()))) {
return contexts.get(0);
}
return null;
@ -119,6 +120,7 @@ public abstract class Util implements I2PConstants {
android.util.Log.i(ANDROID_TAG, m);
}
}
public static void d(String m) {
d(m, null);
}
@ -135,7 +137,9 @@ public abstract class Util implements I2PConstants {
}
}
/** copied from various private components */
/**
* copied from various private components
*/
final static String PROP_I2NP_NTCP_PORT = "i2np.ntcp.port";
final static String PROP_I2NP_NTCP_AUTO_PORT = "i2np.ntcp.autoport";
@ -229,6 +233,7 @@ public abstract class Util implements I2PConstants {
// propName -> defaultValue
private static HashMap<String, Boolean> booleanOptionsRequiringRestart = new HashMap<>();
private static HashMap<String, String> stringOptionsRequiringRestart = new HashMap<>();
static {
HashMap<String, Boolean> boolToAdd = new HashMap<>();
HashMap<String, String> strToAdd = new HashMap<>();
@ -245,6 +250,7 @@ public abstract class Util implements I2PConstants {
booleanOptionsRequiringRestart.putAll(boolToAdd);
stringOptionsRequiringRestart.putAll(strToAdd);
}
/**
* This function performs two tasks:
* <ul><li>
@ -356,12 +362,18 @@ public abstract class Util implements I2PConstants {
File path = new File(dir, file);
DataHelper.storeProps(props, path);
Util.d("Saved " + props.size() +" properties in " + file);
Util.d("Saved " + props.size() + " properties in " + file);
} catch (IOException ioe) {
} catch (Resources.NotFoundException nfe) {
} finally {
if (in != null) try { in.close(); } catch (IOException ioe) {}
if (fin != null) try { fin.close(); } catch (IOException ioe) {}
if (in != null) try {
in.close();
} catch (IOException ioe) {
}
if (fin != null) try {
fin.close();
} catch (IOException ioe) {
}
}
}
@ -393,10 +405,11 @@ public abstract class Util implements I2PConstants {
this.status = status;
}
}
public static NetStatus getNetStatus(Context ctx, RouterContext rCtx) {
if (rCtx.commSystem().isDummy())
return new NetStatus(NetStatus.Level.INFO, ctx.getString(R.string.vm_comm_system));
if (rCtx.router().getUptime() > 60*1000 && (!rCtx.router().gracefulShutdownInProgress()) &&
if (rCtx.router().getUptime() > 60 * 1000 && (!rCtx.router().gracefulShutdownInProgress()) &&
!rCtx.clientManager().isAlive()) // not a router problem but the user should know
return new NetStatus(NetStatus.Level.ERROR, ctx.getString(R.string.net_status_error_i2cp));
// Warn based on actual skew from peers, not update status, so if we successfully offset
@ -404,9 +417,12 @@ public abstract class Util implements I2PConstants {
//if (!rCtx.clock().getUpdatedSuccessfully())
long skew = rCtx.commSystem().getFramedAveragePeerClockSkew(33);
// Display the actual skew, not the offset
if (Math.abs(skew) > 30*1000)
if (Math.abs(skew) > 30 * 1000)
return new NetStatus(NetStatus.Level.ERROR,
ctx.getString(R.string.net_status_error_skew, DataHelper.formatDuration2(Math.abs(skew))));
ctx.getString(R.string.net_status_error_skew,
DataHelper.formatDuration2(Math.abs(skew))
.replace("&minus;", "-")
.replace("&nbsp;", " ")));
if (rCtx.router().isHidden())
return new NetStatus(NetStatus.Level.INFO, ctx.getString(R.string.hidden));
RouterInfo routerInfo = rCtx.router().getRouterInfo();
@ -460,7 +476,7 @@ public abstract class Util implements I2PConstants {
case IPV4_DISABLED_IPV6_UNKNOWN:
default:
ra = routerInfo.getTargetAddress("SSU");
if (ra == null && rCtx.router().getUptime() > 5*60*1000) {
if (ra == null && rCtx.router().getUptime() > 5 * 60 * 1000) {
if (rCtx.commSystem().countActivePeers() <= 0)
return new NetStatus(NetStatus.Level.ERROR, ctx.getString(R.string.net_status_error_no_active_peers));
else if (rCtx.getProperty(ctx.getString(R.string.PROP_I2NP_NTCP_HOSTNAME)) == null ||