1 package com.koushikdutta.superuser.util;
3 import android.content.Context;
4 import android.util.Log;
6 public class SuHelper {
7 public static String CURRENT_VERSION = "9";
8 public static void checkSu(Context context) throws Exception {
9 Process p = Runtime.getRuntime().exec("su -v");
10 String result = Settings.readToEnd(p.getInputStream());
11 Log.i("Superuser", "Result: " + result);
13 throw new Exception("non zero result");
15 throw new Exception("no data");
16 if (!result.contains(context.getPackageName()))
17 throw new Exception("unknown su");
19 String[] parts = result.split(" ");
20 if (!CURRENT_VERSION.equals(parts[0]))
21 throw new Exception("binary is old");