MD5還是有辦法取得的!
只要在指令後方加入-v 便大功告成
$ keytool -list -alias androiddebugkey -keystore.keystore -storepass android -keypass android -v
$ keytool -list -alias androiddebugkey -keystore.keystore -storepass android -keypass android -v
public class TESTTPERMISSION extends Activity {
private static final String TAG = "execCommand";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setTitle("This is Matrix.");
runRootCommand("/data/local/bin/D2MCEDaemon");
}
public static boolean runRootCommand(String command) {
Process process = null;
DataOutputStream os = null;
try {
process = Runtime.getRuntime().exec(command);
// Log.e("runRootCommand", "su");
os = new DataOutputStream(process.getOutputStream());
// os.writeBytes(command+"\n");
Log.e("runRootCommand", command);
//os.writeBytes("exit\n");
os.flush();
process.waitFor();
String line = null;
InputStream stderr = process.getErrorStream();
InputStreamReader esr = new InputStreamReader(stderr);
BufferedReader ebr = new BufferedReader(esr);
System.out.println("");
while ((line = ebr.readLine()) != null) {
System.out.println(line);
Log.e("runRootCommand", line);
}
System.out.println(" ");
InputStream stdout = process.getInputStream();
InputStreamReader osr = new InputStreamReader(stdout);
BufferedReader obr = new BufferedReader(osr);
System.out.println("");
int exitVal = process.waitFor ();
System.out.println ("Process exitValue: " + exitVal);
Log.e("runRootCommand", String.valueOf(exitVal));
} catch (Exception e) {
Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());
return false;
}
finally {
try {
if (os != null) {
os.close();
}
process.destroy();
} catch (Exception e) {
// nothing
}
}
return true;
}
}