コード例 #1
0
 /// <summary>
 /// Check that su exists with "which su" command.
 /// </summary>
 /// <returns><c>true</c>, if su exists, <c>false</c> otherwise.</returns>
 private bool CheckSuExists()
 {
     Java.Lang.Process process = null;
     try
     {
         process = Runtime.GetRuntime().Exec(new string[] { "/system/xbin/which", "su" });
         Java.IO.BufferedReader input = new Java.IO.BufferedReader(
             new Java.IO.InputStreamReader(process.InputStream));
         if (input.ReadLine() != null)
         {
             return(true);
         }
         return(false);
     }
     catch (Throwable)
     {
         return(false);
     }
     finally
     {
         if (process != null)
         {
             process.Destroy();
         }
     }
 }
コード例 #2
0
        private static string ExecuteTop()
        {
            Java.Lang.Process p = null;
            BufferedReader    reader;
            string            returnString = null;

            try
            {
                p      = Runtime.GetRuntime().Exec("top -n 1");
                reader = new BufferedReader(new InputStreamReader(p.InputStream));
                while (returnString == null || returnString.Equals(""))
                {
                    returnString = reader.ReadLine();
                }
            }
            catch (System.IO.IOException e)
            {
            }
            finally
            {
                try
                {
                    //reader.Close();
                    p.Destroy();
                }
                catch (System.IO.IOException e)
                {
                    //Log.e("executeTop",
                    //        "error in closing and destroying top process");
                    //e.printStackTrace();
                }
            }
            return(returnString);
        }
コード例 #3
0
        private void _StopProcess()
        {
            try
            {
                if (m_Reader != null)
                {
                    m_Reader.Interrupt();
                }

                if (m_Process != null)
                {
                    m_Process.Destroy();
                }
            }
            catch (Exception e)
            {
                e.PrintStackTrace();
            }
        }
コード例 #4
0
        private static bool CheckUsingProcessPermissions()
        {
            Process process = null;

            try
            {
                process = Runtime.GetRuntime().Exec(new[] { "/system/xbin/which", "su" });

                using (var input = new BufferedReader(new InputStreamReader(process.InputStream)))
                {
                    return(input.ReadLine() != null);
                }
            }
            catch
            {
                return(false);
            }
            finally
            {
                process?.Destroy();
            }
        }
コード例 #5
0
 void StopNode()
 {
     if (nodeProcess != null)
     {
         try
         {
             if (nodeProcess.IsAlive)
             {
                 nodeProcess.Destroy();
             }
         }
         catch (Java.Lang.Exception e)
         {
             Log.Error(GetType().Name, e.ToString());
         }
         finally
         {
             try { nodeProcess.Dispose(); }
             catch { }
             nodeProcess = null;
         }
     }
 }
コード例 #6
0
        public bool IsRooted()
        {
            bool isEmulator = IsEmulator();

            if (isEmulator)
            {
                return(false);
            }

            // Check from build info
            var buildTags = Build.Tags;

            if (buildTags != null &&
                buildTags.Contains("test-keys"))
            {
                return(true);
            }

            if (new File("/system/app/Superuser.apk").Exists())
            {
                return(true);
            }

            var pathList = new string[]
            {
                "/system/xbin/su",
                "/system/bin/su",
                "/data/local/su",
                "/su/bin/su"
            };

            foreach (var path in pathList)
            {
                if (new File(path).Exists())
                {
                    return(true);
                }
            }

            Java.Lang.Process process = null;
            try
            {
                process = Runtime.GetRuntime().Exec(new string[] { "/system/xbin/which", "su" });
                BufferedReader br = new BufferedReader(new InputStreamReader(process.InputStream));
                if (br.ReadLine() != null)
                {
                    return(true);
                }
            }
            catch (Throwable)
            {
            }
            finally
            {
                if (process != null)
                {
                    process.Destroy();
                }
            }

            return(false);
        }