Changeset 74e7539


Ignore:
Timestamp:
Sep 9, 2012 3:40:14 PM (8 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
2f98d05
Parents:
9bc54f2
Message:
  • SystemVersion?: New util, to consolidate duplicate code, and determine Java version on Android
Files:
1 added
23 edited

Legend:

Unmodified
Added
Removed
  • apps/addressbook/java/src/net/i2p/addressbook/ConfigParser.java

    r9bc54f2 r74e7539  
    3838import net.i2p.util.SecureFile;
    3939import net.i2p.util.SecureFileOutputStream;
     40import net.i2p.util.SystemVersion;
    4041
    4142/**
     
    5051class ConfigParser {
    5152
    52     private static final boolean isWindows = System.getProperty("os.name").startsWith("Win");
     53    private static final boolean isWindows = SystemVersion.isWindows();
    5354
    5455    /**
  • apps/i2psnark/java/src/org/klomp/snark/Storage.java

    r9bc54f2 r74e7539  
    3737import net.i2p.util.Log;
    3838import net.i2p.util.SecureFile;
     39import net.i2p.util.SystemVersion;
    3940
    4041/**
     
    7879  private static final Map<String, String> _filterNameCache = new ConcurrentHashMap();
    7980
    80   private static final boolean _isWindows = System.getProperty("os.name").startsWith("Win");
     81  private static final boolean _isWindows = SystemVersion.isWindows();
    8182
    8283  /**
  • apps/routerconsole/java/src/net/i2p/router/web/ConfigServiceHandler.java

    r9bc54f2 r74e7539  
    99import net.i2p.router.RouterContext;
    1010import net.i2p.router.startup.ClientAppConfig;
     11import net.i2p.util.SystemVersion;
    1112import net.i2p.util.VersionComparator;
    1213
     
    141142    synchronized static void registerSignalHandler(RouterContext ctx) {
    142143        if (ctx.hasWrapper() && _wrapperListener == null &&
    143             !System.getProperty("os.name").startsWith("Win")) {
     144            !SystemVersion.isWindows()) {
    144145            String wv = System.getProperty("wrapper.version");
    145146            if (wv != null && (new VersionComparator()).compare(wv, LISTENER_AVAILABLE) >= 0) {
  • apps/routerconsole/java/src/net/i2p/router/web/StatSummarizer.java

    r9bc54f2 r74e7539  
    2424import net.i2p.util.FileUtil;
    2525import net.i2p.util.Log;
     26import net.i2p.util.SystemVersion;
    2627
    2728import org.jrobin.core.RrdException;
     
    419420    }
    420421
    421     private static final boolean IS_WIN = System.getProperty("os.name").startsWith("Win");
     422    private static final boolean IS_WIN = SystemVersion.isWindows();
    422423
    423424    /** translate a string */
  • apps/routerconsole/java/src/net/i2p/router/web/SummaryRenderer.java

    r9bc54f2 r74e7539  
    1919import net.i2p.router.util.EventLog;
    2020import net.i2p.util.Log;
     21import net.i2p.util.SystemVersion;
    2122
    2223import org.jrobin.core.RrdException;
     
    222223    }
    223224
    224     private static final boolean IS_WIN = System.getProperty("os.name").startsWith("Win");
     225    private static final boolean IS_WIN = SystemVersion.isWindows();
    225226
    226227    /** translate a string */
  • apps/systray/java/src/net/i2p/apps/systray/SysTray.java

    r9bc54f2 r74e7539  
    1616import net.i2p.util.SimpleScheduler;
    1717import net.i2p.util.SimpleTimer;
     18import net.i2p.util.SystemVersion;
    1819
    1920import snoozesoft.systray4j.SysTrayMenu;
     
    3839    private static boolean        _showIcon;
    3940    private static UrlLauncher    _urlLauncher    = new UrlLauncher();
    40     private static final boolean _is64 = "64".equals(System.getProperty("sun.arch.data.model")) ||
    41                                          System.getProperty("os.arch").contains("64");
     41    private static final boolean _is64 = SystemVersion.is64Bit();
    4242
    4343    static {
     
    5555        //    openRouterConsole("http://localhost:" + _portString + "/index.jsp");
    5656
    57         if ( (System.getProperty("os.name").startsWith("Windows")) && (!Boolean.getBoolean("systray.disable")) && (!_is64))
     57        if ( (SystemVersion.isWindows()) && (!Boolean.getBoolean("systray.disable")) && (!_is64))
    5858            _instance = new SysTray();
    5959    }
  • apps/systray/java/src/net/i2p/apps/systray/UrlLauncher.java

    r9bc54f2 r74e7539  
    2424import net.i2p.I2PAppContext;
    2525import net.i2p.util.ShellCommand;
     26import net.i2p.util.SystemVersion;
    2627
    2728/**
     
    125126                    return true;
    126127
    127             } else if (osName.startsWith("Windows")) {
     128            } else if (SystemVersion.isWindows()) {
    128129
    129130                String         browserString  = "\"C:\\Program Files\\Internet Explorer\\iexplore.exe\" -nohome";
  • core/java/src/freenet/support/CPUInformation/CPUID.java

    r9bc54f2 r74e7539  
    2020import net.i2p.I2PAppContext;
    2121import net.i2p.util.FileUtil;
     22import net.i2p.util.SystemVersion;
    2223
    2324
     
    5152    private static final boolean isX86 = System.getProperty("os.arch").contains("86") ||
    5253                                         System.getProperty("os.arch").equals("amd64");
    53     private static final String libPrefix = (System.getProperty("os.name").startsWith("Win") ? "" : "lib");
    54     private static final String libSuffix = (System.getProperty("os.name").startsWith("Win") ? ".dll" : ".so");
    55     private static final boolean isWindows = System.getProperty("os.name").toLowerCase(Locale.US).contains("windows");
     54    private static final boolean isWindows = SystemVersion.isWindows();
     55    private static final String libPrefix = isWindows ? "" : "lib";
     56    private static final String libSuffix = isWindows ? ".dll" : ".so";
    5657    private static final boolean isLinux = System.getProperty("os.name").toLowerCase(Locale.US).contains("linux");
    5758    private static final boolean isFreebsd = System.getProperty("os.name").toLowerCase(Locale.US).contains("freebsd");
     
    5960    private static final boolean isOpenbsd = System.getProperty("os.name").toLowerCase(Locale.US).contains("openbsd");
    6061    private static final boolean isSunos = System.getProperty("os.name").toLowerCase(Locale.US).contains("sunos");
    61     private static final boolean isMac = System.getProperty("os.name").startsWith("Mac");
     62    private static final boolean isMac = SystemVersion.isMac();
    6263
    6364
     
    7273     * os.arch contains "64" could be 32 or 64 bit libs
    7374     */
    74     private static final boolean is64 = "64".equals(System.getProperty("sun.arch.data.model")) ||
    75                                         System.getProperty("os.arch").contains("64");
     75    private static final boolean is64 = SystemVersion.is64Bit();
    7676
    7777    static
  • core/java/src/net/i2p/util/BigPipedInputStream.java

    r9bc54f2 r74e7539  
    1616public class BigPipedInputStream extends PipedInputStream {
    1717
    18     private static final boolean oneDotSix =
    19         (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0;
     18    private static final boolean oneDotSix = SystemVersion.isJava6();
    2019
    2120    private static final int PIPE_SIZE = 64*1024;
  • core/java/src/net/i2p/util/FileUtil.java

    r9bc54f2 r74e7539  
    453453            return false;
    454454        boolean success = false;
    455         boolean isWindows = System.getProperty("os.name").startsWith("Win");
     455        boolean isWindows = SystemVersion.isWindows();
    456456        // overwrite fails on windows
    457457        if (!isWindows)
  • core/java/src/net/i2p/util/NativeBigInteger.java

    r9bc54f2 r74e7539  
    159159     * Operating systems
    160160     */
    161     private static final boolean _isWin = System.getProperty("os.name").startsWith("Win");
     161    private static final boolean _isWin = SystemVersion.isWindows();
    162162    private static final boolean _isOS2 = System.getProperty("os.name").startsWith("OS/2");
    163     private static final boolean _isMac = System.getProperty("os.name").startsWith("Mac");
     163    private static final boolean _isMac = SystemVersion.isMac();
    164164    private static final boolean _isLinux = System.getProperty("os.name").toLowerCase(Locale.US).contains("linux");
    165165    private static final boolean _isFreebsd = System.getProperty("os.name").toLowerCase(Locale.US).contains("freebsd");
     
    167167    private static final boolean _isOpenbsd = System.getProperty("os.name").toLowerCase(Locale.US).contains("openbsd");
    168168    private static final boolean _isSunos = System.getProperty("os.name").toLowerCase(Locale.US).contains("sunos");
    169     private static final boolean _isAndroid = System.getProperty("java.vendor").contains("Android");
     169    private static final boolean _isAndroid = SystemVersion.isAndroid();
    170170
    171171    /*
     
    179179     * os.arch contains "64" could be 32 or 64 bit libs
    180180     */
    181     private static final boolean _is64 = "64".equals(System.getProperty("sun.arch.data.model")) ||
    182                                          System.getProperty("os.arch").contains("64");
     181    private static final boolean _is64 = SystemVersion.is64Bit();
    183182
    184183    private static final boolean _isX86 = System.getProperty("os.arch").contains("86") ||
  • core/java/src/net/i2p/util/ReusableGZIPInputStream.java

    r9bc54f2 r74e7539  
    1111    // Neither does Android
    1212    private static final boolean ENABLE_CACHING = !(System.getProperty("java.vendor").startsWith("Apache") ||
    13                                                     System.getProperty("java.vendor").contains("Android"));
     13                                                    SystemVersion.isAndroid());
    1414    private static final LinkedBlockingQueue<ReusableGZIPInputStream> _available;
    1515    static {
  • core/java/src/net/i2p/util/ReusableGZIPOutputStream.java

    r9bc54f2 r74e7539  
    2222    // Neither does Android
    2323    private static final boolean ENABLE_CACHING = !(System.getProperty("java.vendor").startsWith("Apache") ||
    24                                                     System.getProperty("java.vendor").contains("Android"));
     24                                                    SystemVersion.isAndroid());
    2525    private static final LinkedBlockingQueue<ReusableGZIPOutputStream> _available;
    2626    static {
  • core/java/src/net/i2p/util/SSLEepGet.java

    r9bc54f2 r74e7539  
    9292    private SavingTrustManager _stm;
    9393
    94     private static final boolean _isAndroid = System.getProperty("java.vendor").contains("Android");
     94    private static final boolean _isAndroid = SystemVersion.isAndroid();
    9595
    9696    /**
  • core/java/src/net/i2p/util/SecureDirectory.java

    r9bc54f2 r74e7539  
    1313public class SecureDirectory extends File {
    1414
    15     protected static final boolean isNotWindows = !System.getProperty("os.name").startsWith("Win");
     15    protected static final boolean isNotWindows = !SystemVersion.isWindows();
    1616
    1717    public SecureDirectory(String pathname) {
  • core/java/src/net/i2p/util/SecureFileOutputStream.java

    r9bc54f2 r74e7539  
    1616public class SecureFileOutputStream extends FileOutputStream {
    1717
    18     private static final boolean oneDotSix =
    19         (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0;
     18    private static final boolean oneDotSix = SystemVersion.isJava6();
    2019
    2120    /**
  • router/java/src/net/i2p/router/Router.java

    r9bc54f2 r74e7539  
    5353import net.i2p.util.SimpleByteCache;
    5454import net.i2p.util.SimpleScheduler;
     55import net.i2p.util.SystemVersion;
    5556
    5657/**
     
    208209        if (contexts.isEmpty()) {
    209210            RouterContext.killGlobalContext();
    210         } else if (System.getProperty("java.vendor").contains("Android")) {
     211        } else if (SystemVersion.isAndroid()) {
    211212            System.err.println("Warning: Killing " + contexts.size() + " other routers in this JVM");
    212213            contexts.clear();
     
    261262        //
    262263        // NOW we can start the ping file thread.
    263         if (!System.getProperty("java.vendor").contains("Android"))
     264        if (!SystemVersion.isAndroid())
    264265            beginMarkingLiveliness();
    265266
     
    889890            // allow the Runtime shutdown hooks to execute
    890891            Runtime.getRuntime().exit(exitCode);
    891         } else if (System.getProperty("java.vendor").contains("Android")) {
     892        } else if (SystemVersion.isAndroid()) {
    892893            Runtime.getRuntime().gc();
    893894        }
     
    12181219            boolean isX86 = osArch.contains("86") || osArch.equals("amd64");
    12191220            String osName = System.getProperty("os.name").toLowerCase(Locale.US);
    1220             boolean isWin = osName.startsWith("win");
    1221             boolean isMac = osName.startsWith("mac");
     1221            boolean isWin = SystemVersion.isWindows();
     1222            boolean isMac = SystemVersion.isMac();
    12221223            // only do this on these OSes
    12231224            boolean goodOS = isWin || isMac ||
  • router/java/src/net/i2p/router/startup/StartupJob.java

    r9bc54f2 r74e7539  
    1212import net.i2p.router.JobImpl;
    1313import net.i2p.router.RouterContext;
     14import net.i2p.util.SystemVersion;
    1415
    1516/**
     
    3435    public String getName() { return "Startup Router"; }
    3536    public void runJob() {
    36         if (!System.getProperty("java.vendor").contains("Android"))
     37        if (!SystemVersion.isAndroid())
    3738            getContext().jobQueue().addJob(new LoadClientAppsJob(getContext()));
    3839        getContext().statPublisher().startup();
  • router/java/src/net/i2p/router/startup/WorkingDir.java

    r9bc54f2 r74e7539  
    1414import net.i2p.util.SecureDirectory;
    1515import net.i2p.util.SecureFileOutputStream;
     16import net.i2p.util.SystemVersion;
    1617
    1718/**
     
    7071        if (dir == null)
    7172            dir = System.getProperty(PROP_WORKING_DIR);
    72         boolean isWindows = System.getProperty("os.name").startsWith("Win");
     73        boolean isWindows = SystemVersion.isWindows();
    7374        File dirf = null;
    7475        if (dir != null) {
  • router/java/src/net/i2p/router/tasks/RouterWatchdog.java

    r9bc54f2 r74e7539  
    1212import net.i2p.util.ShellCommand;
    1313import net.i2p.util.Log;
     14import net.i2p.util.SystemVersion;
    1415
    1516/**
     
    113114                // It won't on windows, and we can't call i2prouter.bat either, it does something
    114115                // completely different...
    115                 if (_context.hasWrapper() && !System.getProperty("os.name").startsWith("Win")) {
     116                if (_context.hasWrapper() && !SystemVersion.isWindows()) {
    116117                    ShellCommand sc = new ShellCommand();
    117118                    File i2pr = new File(_context.getBaseDir(), "i2prouter");
  • router/java/src/net/i2p/router/transport/udp/MTU.java

    r9bc54f2 r74e7539  
    66import java.util.Enumeration;
    77
    8 import net.i2p.util.VersionComparator;
     8import net.i2p.util.SystemVersion;
    99
    1010/**
     
    1515abstract class MTU {
    1616
    17     private static final boolean hasMTU =
    18         (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0;
     17    private static final boolean hasMTU = SystemVersion.isJava6();
    1918   
    2019    /**
  • router/java/src/net/i2p/router/transport/udp/UDPReceiver.java

    r9bc54f2 r74e7539  
    1212import net.i2p.util.Log;
    1313import net.i2p.util.SimpleTimer;
     14import net.i2p.util.SystemVersion;
    1415
    1516/**
     
    3334    private final int _id;
    3435
    35     private static final boolean _isAndroid = System.getProperty("java.vendor").contains("Android");
     36    private static final boolean _isAndroid = SystemVersion.isAndroid();
    3637
    3738    private static final int TYPE_POISON = -99999;
  • router/java/src/net/i2p/router/util/RandomIterator.java

    r9bc54f2 r74e7539  
    1515
    1616import net.i2p.util.RandomSource;
     17import net.i2p.util.SystemVersion;
    1718
    1819/**
     
    9091    private int lower, upper;
    9192
    92     private static final boolean isAndroid = System.getProperty("java.vendor").contains("Android");
    93 
     93    private static final boolean hasAndroidBug;
    9494    static {
    95         if (isAndroid)
    96             testAndroid();
     95        if (SystemVersion.isAndroid()) {
     96            // only present on Gingerbread (API 11), but set if version check failed also
     97            int ver = SystemVersion.getAndroidVersion();
     98            hasAndroidBug = ver == 11 || ver == 0;
     99            if (hasAndroidBug)
     100                testAndroid();
     101        } else {
     102            hasAndroidBug = false;
     103        }
    97104    }
    98105
     
    138145            if (index == lower)
    139146                // workaround for Android ICS bug - see below
    140                 lower = isAndroid ? nextClearBit(index) : served.nextClearBit(index);
     147                lower = hasAndroidBug ? nextClearBit(index) : served.nextClearBit(index);
    141148            else if (index == upper)
    142149                upper = previousClearBit(index - 1);
     
    200207     */
    201208    private static void testAndroid() {
    202         System.out.println("checking for Android bug");
     209        System.out.println("Checking for Android BitSet bug");
    203210        BitSet theBitSet = new BitSet(864);
    204211        for (int exp =0; exp < 864; exp++) {
Note: See TracChangeset for help on using the changeset viewer.