Home > Back-end >  [appeal] to understand the shell bosses come in and see, don't know why I can't write the
[appeal] to understand the shell bosses come in and see, don't know why I can't write the

Time:09-15


//cell phone has a root, these commands with MT manager can perform
//don't know why my app may not be able to perform

Public static String exec (String command) {

Process Process=null;
BufferedReader reader=null;
InputStreamReader is=null;
DataOutputStream OS=null;

Try {
The process=Runtime. GetRuntime (). The exec (" su ");
Is=new InputStreamReader (process. GetInputStream ());
Reader=new BufferedReader (is);
OS=new DataOutputStream (process. GetOutputStream ());
OS. WriteBytes (" mount -o rw, remount/system \ n ");
os.flush();
OS. WriteBytes (" cp/sdcard/test/system/app/yry. The apk \ n ");
os.flush();
OS. WriteBytes (" chmod 644./system/app/yry apk \ n ");
os.flush();
OS. WriteBytes (" exit \ n ");
os.flush();
Int read;
Char [] buffer=new char [4096].
The StringBuilder output=new StringBuilder ();
While ((read=reader. Read (buffer)) & gt; 0 {
Output. Append (buffer, 0, read);
}
Process. The waitFor ();
Return the output. The toString ();
} the catch (IOException | InterruptedException e) {
throw new RuntimeException(e);
} the finally {
Try {
if (os !=null) {
os.close();
}

If (reader!=null) {
Reader. The close ();
}

If (is!=null) {
is.close();
}

If (the process!=null) {
Process. The destroy ();
}
} the catch (IOException e) {
e.printStackTrace();
}
}
}
  • Related