Search in sources :

Example 1 with StructUtsname

use of libcore.io.StructUtsname in project XobotOS by xamarin.

the class System method initSystemProperties.

private static void initSystemProperties() {
    VMRuntime runtime = VMRuntime.getRuntime();
    Properties p = new Properties();
    String projectUrl = "http://www.android.com/";
    String projectName = "The Android Project";
    p.put("java.boot.class.path", runtime.bootClassPath());
    p.put("java.class.path", runtime.classPath());
    // None of these four are meaningful on Android, but these keys are guaranteed
    // to be present for System.getProperty. For java.class.version, we use the maximum
    // class file version that dx currently supports.
    p.put("java.class.version", "50.0");
    p.put("java.compiler", "");
    p.put("java.ext.dirs", "");
    p.put("java.version", "0");
    p.put("java.home", getenv("JAVA_HOME", "/system"));
    p.put("java.io.tmpdir", "/tmp");
    p.put("java.library.path", getenv("LD_LIBRARY_PATH"));
    p.put("java.specification.name", "Dalvik Core Library");
    p.put("java.specification.vendor", projectName);
    p.put("java.specification.version", "0.9");
    p.put("java.vendor", projectName);
    p.put("java.vendor.url", projectUrl);
    p.put("java.vm.name", "Dalvik");
    p.put("java.vm.specification.name", "Dalvik Virtual Machine Specification");
    p.put("java.vm.specification.vendor", projectName);
    p.put("java.vm.specification.version", "0.9");
    p.put("java.vm.vendor", projectName);
    p.put("java.vm.version", runtime.vmVersion());
    p.put("file.separator", "/");
    p.put("line.separator", "\n");
    p.put("path.separator", ":");
    p.put("java.runtime.name", "Android Runtime");
    p.put("java.runtime.version", "0.9");
    p.put("java.vm.vendor.url", projectUrl);
    p.put("file.encoding", "UTF-8");
    p.put("user.language", "en");
    p.put("user.region", "US");
    p.put("user.home", getenv("HOME", ""));
    p.put("user.name", getenv("USER", ""));
    StructUtsname info = Libcore.os.uname();
    p.put("os.arch", info.machine);
    p.put("os.name", info.sysname);
    p.put("os.version", info.release);
    // Undocumented Android-only properties.
    p.put("android.icu.library.version", ICU.getIcuVersion());
    p.put("android.icu.unicode.version", ICU.getUnicodeVersion());
    // TODO: it would be nice to have this but currently it causes circularity.
    // p.put("android.tzdata.version", ZoneInfoDB.getVersion());
    parsePropertyAssignments(p, specialProperties());
    // Override built-in properties with settings from the command line.
    parsePropertyAssignments(p, runtime.properties());
    systemProperties = p;
}
Also used : VMRuntime(dalvik.system.VMRuntime) StructUtsname(libcore.io.StructUtsname) Properties(java.util.Properties)

Example 2 with StructUtsname

use of libcore.io.StructUtsname in project robovm by robovm.

the class System method initSystemProperties.

private static void initSystemProperties() {
    VMRuntime runtime = VMRuntime.getRuntime();
    Properties p = new Properties();
    String projectUrl = "http://www.robovm.org/";
    String projectName = "RoboVM";
    p.put("java.boot.class.path", runtime.bootClassPath());
    p.put("java.class.path", runtime.classPath());
    // None of these four are meaningful on Android, but these keys are guaranteed
    // to be present for System.getProperty. For java.class.version, we use the maximum
    // class file version that dx currently supports.
    p.put("java.class.version", "50.0");
    p.put("java.compiler", "");
    p.put("java.ext.dirs", "");
    p.put("java.version", "0");
    // RoboVM note: Android uses getenv("JAVA_HOME") here with "/system" as fallback.
    p.put("java.home", VM.resourcesPath());
    // RoboVM note: Use value of $TMPDIR if set. Otherwise use /tmp as Android does.
    String tmpdir = getenv("TMPDIR");
    p.put("java.io.tmpdir", tmpdir != null ? tmpdir : "/tmp");
    String ldLibraryPath = getenv("LD_LIBRARY_PATH");
    if (ldLibraryPath != null) {
        p.put("java.library.path", ldLibraryPath);
    }
    p.put("java.specification.name", "RoboVM Core Library");
    p.put("java.specification.vendor", projectName);
    p.put("java.specification.version", "0.9");
    p.put("java.vendor", projectName);
    p.put("java.vendor.url", projectUrl);
    p.put("java.vm.name", "RoboVM");
    p.put("java.vm.specification.name", "RoboVM Virtual Machine Specification");
    p.put("java.vm.specification.vendor", projectName);
    p.put("java.vm.specification.version", "0.9");
    p.put("java.vm.vendor", projectName);
    p.put("java.vm.version", runtime.vmVersion());
    p.put("file.separator", "/");
    p.put("line.separator", "\n");
    p.put("path.separator", ":");
    p.put("java.runtime.name", "RoboVM Runtime");
    p.put("java.runtime.version", "0.9");
    p.put("java.vm.vendor.url", projectUrl);
    p.put("file.encoding", "UTF-8");
    p.put("user.language", "en");
    p.put("user.region", "US");
    try {
        StructPasswd passwd = Libcore.os.getpwuid(Libcore.os.getuid());
        p.put("user.home", passwd.pw_dir);
        p.put("user.name", passwd.pw_name);
    } catch (ErrnoException exception) {
        // RoboVM note: Start change. Fall back to environment variables. getpwuid() fails on the iOS simulator.
        String home = getenv("HOME");
        String user = getenv("USER");
        p.put("user.home", home != null ? home : "");
        p.put("user.name", user != null ? user : "");
    // RoboVM note: End change.
    }
    StructUtsname info = Libcore.os.uname();
    p.put("os.arch", info.machine);
    p.put("os.name", info.sysname);
    p.put("os.version", info.release);
    // Undocumented Android-only properties.
    p.put("android.icu.library.version", ICU.getIcuVersion());
    p.put("android.icu.unicode.version", ICU.getUnicodeVersion());
    p.put("android.icu.cldr.version", ICU.getCldrVersion());
    parsePropertyAssignments(p, specialProperties());
    parsePropertyAssignments(p, robovmSpecialProperties());
    // user.home, user.dir and user.name values on iOS.
    if (p.getProperty("os.name").contains("iOS")) {
        // On iOS we want user.home and user.dir to point to the app's data
        // container root dir. This is the dir $HOME points to. We also set
        // user.name to $USER or hardcode 'mobile' if $USER isn't set (iOS
        // simulator).
        String home = getenv("HOME");
        String user = getenv("USER");
        p.put("user.home", home != null ? home : "");
        p.put("user.dir", home != null ? home : "/");
        p.put("user.name", user != null ? user : "mobile");
    }
    // RoboVM note: End change.
    // Override built-in properties with settings from the command line.
    parsePropertyAssignments(p, runtime.properties());
    systemProperties = p;
}
Also used : VMRuntime(dalvik.system.VMRuntime) ErrnoException(libcore.io.ErrnoException) StructUtsname(libcore.io.StructUtsname) Properties(java.util.Properties) StructPasswd(libcore.io.StructPasswd)

Aggregations

VMRuntime (dalvik.system.VMRuntime)2 Properties (java.util.Properties)2 StructUtsname (libcore.io.StructUtsname)2 ErrnoException (libcore.io.ErrnoException)1 StructPasswd (libcore.io.StructPasswd)1