Example usage for android.os Build TIME

List of usage examples for android.os Build TIME

Introduction

In this page you can find the example usage for android.os Build TIME.

Prototype

long TIME

To view the source code for android.os Build TIME.

Click Source Link

Usage

From source file:org.zeroxlab.benchmark.Benchmark.java

public String getXMLResult() {
    if (mCases.size() == 0)
        return "";

    Date date = new Date();
    //2010-05-28T17:40:25CST
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz");

    String xml = "";
    xml += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    xml += "<result";
    xml += " executedTimestamp=\"" + sdf.format(date) + "\"";
    xml += " manufacturer=\"" + Build.MANUFACTURER.replace(' ', '_') + "\"";
    xml += " model=\"" + Build.MODEL.replace(' ', '_') + ":" + Build.DISPLAY + "\"";
    xml += " buildTimestamp=\"" + sdf.format(new Date(Build.TIME)) + "\"";
    xml += " orientation=\"" + Integer.toString(orientation) + "\"";

    try { // read kernel version
        BufferedReader procVersion = new BufferedReader(new FileReader("/proc/version"));
        StringBuffer sbuff = new StringBuffer();
        String tmp;//from www. j a va2  s.  c  o  m
        while ((tmp = procVersion.readLine()) != null)
            sbuff.append(tmp);
        procVersion.close();
        tmp = sbuff.toString().replace("[\n\r]+", " ").replace(" +", ".");
        xml += " version=\"" + tmp + "\"";
    } catch (IOException e) {
        Log.e(TAG, "opening /proc/version failed: " + e.toString());
    }

    try { // read and parse cpu info
        BufferedReader procVersion = new BufferedReader(new FileReader("/proc/cpuinfo"));
        StringBuffer sbuff = new StringBuffer();
        String tmp;
        while ((tmp = procVersion.readLine()) != null)
            sbuff.append(tmp + "\n");
        procVersion.close();

        tmp = sbuff.toString();

        sbuff = new StringBuffer();

        Pattern p1 = Pattern.compile("(Processor\\s*:\\s*(.*)\\s*[\n\r]+)");
        Matcher m1 = p1.matcher(tmp);
        if (m1.find())
            sbuff.append(m1.group(2));

        Pattern p2 = Pattern.compile("(Hardware\\s*:\\s*(.*)\\s*[\n\r]+)");
        Matcher m2 = p2.matcher(tmp);
        if (m2.find())
            sbuff.append(":" + m2.group(2));

        Pattern p3 = Pattern.compile("(Revision\\s*:\\s*(.*)\\s*[\n\r]+)");
        Matcher m3 = p3.matcher(tmp);
        if (m3.find())
            sbuff.append(":" + m3.group(2));

        Log.e(TAG, sbuff.toString());
        xml += " cpu=\"" + sbuff.toString() + "\"";
    } catch (IOException e) {
        Log.e(TAG, "opening /proc/version failed: " + e.toString());
    }

    xml += ">";

    Case mycase;
    for (int i = 0; i < mCases.size(); i++) {
        mycase = mCases.get(i);
        xml += mycase.getXMLBenchmark();
    }

    xml += "</result>";
    return xml;
}