public static Boolean IsRooted() { try { Java.Lang.Process su = Java.Lang.Runtime.GetRuntime().Exec("su"); Java.IO.DataOutputStream outSu = new Java.IO.DataOutputStream(su.OutputStream); outSu.WriteBytes("exit\n"); outSu.Flush(); su.WaitFor(); return(su.ExitValue() == 0); } catch (Java.Lang.Exception) { return(false); } }
public static bool IsRooted() { bool retval = false; Java.Lang.Process suProcess; try { suProcess = Runtime.GetRuntime().Exec("su"); var os = new Java.IO.DataOutputStream(suProcess.OutputStream); var osRes = new Java.IO.DataInputStream(suProcess.InputStream); if (null != os && null != osRes) { os.WriteBytes("id\n"); os.Flush(); string currUid = osRes.ReadLine(); bool exitSu = false; if (null == currUid) { retval = false; exitSu = false; System.Console.WriteLine("Can't get root access or denied by user"); } else if (true == currUid.Contains("uid=0")) { retval = true; exitSu = true; System.Console.WriteLine("Root access granted"); } else { retval = false; exitSu = true; System.Console.WriteLine("Root access rejected: " + currUid); } if (exitSu) { os.WriteBytes("exit\n"); os.Flush(); } } } catch (Java.Lang.Exception e) { retval = false; System.Console.WriteLine("Root access rejected [" + e.Class.Name + "] : " + e.Message); } return(retval); }
public static Boolean IsRooted () { try { Java.Lang.Process su = Java.Lang.Runtime.GetRuntime ().Exec ("su"); Java.IO.DataOutputStream outSu = new Java.IO.DataOutputStream (su.OutputStream); outSu.WriteBytes ("exit\n"); outSu.Flush (); su.WaitFor (); return su.ExitValue () == 0; } catch (Java.Lang.Exception) { return false; } }
public ProcessHelper () { process = Java.Lang.Runtime.GetRuntime ().Exec ("su"); outP = new Java.IO.DataOutputStream (process.OutputStream); inP = new Java.IO.DataInputStream (process.InputStream); }
public ProcessHelper() { process = Java.Lang.Runtime.GetRuntime().Exec("su"); outP = new Java.IO.DataOutputStream(process.OutputStream); inP = new Java.IO.DataInputStream(process.InputStream); }