upv
upv

Reputation: 539

Android kernel version name

I have successfully build Gingerbread 2.3.4 for beagleboard xM rev C. Now i want to check Linux kernel version name inside a script which runs after the init.rc. In linux we can find the same using the command uname -r. But it is not found in android kernel. can somebody help me with some sample script to do the same.

Upvotes: 8

Views: 11709

Answers (6)

user3826696
user3826696

Reputation: 1135

This worked for me

public static String getKernelVersion() {
    try {
        Process p = Runtime.getRuntime().exec("uname -a");
        InputStream is = null;
        if (p.waitFor() == 0) {
            is = p.getInputStream();
        } else {
            is = p.getErrorStream();
        }
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = br.readLine();
        Log.i("Kernel Version", line);
        br.close();
        return line;
    } catch (Exception ex) {
        return "ERROR: " + ex.getMessage();
    }
}

Upvotes: 2

VishalKale
VishalKale

Reputation: 798

You can get kernel version using

adb shell cat /proc/version

or with the help of

System.getProperty("os.version");

Upvotes: 2

Aniket Thakur
Aniket Thakur

Reputation: 68935

If your phone is rooted and BusyBox is installed then uname -r should work.

enter image description here

Upvotes: 2

Dyonisos
Dyonisos

Reputation: 3539

There is a version file in the /proc directory. Try cat /proc/version in a shell and it should display informations about your kernel.

Upvotes: 9

vkoppula
vkoppula

Reputation: 114

'uname -r' command also should work

Upvotes: -1

Related Questions