android 에서 ps를 호출하여 어떤 프로세서들이 동작하는지 확인 할 수 있을까?
권한이 없는건 아닐까 테스트 해보았습니다.
ps 의 경우 user버전에서 동작할까?
결론 : 잘 동작함
private void test100() { Utils.RunExec("ps"); }
public static String RunExec(String cmd) { String result = null; Runtime runtime = Runtime.getRuntime(); java.lang.Process process; try { process = runtime.exec(cmd); BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); String line ; while ((line = br.readLine()) != null) { Log.i("test",line); if( result == null ) result = line; else result = result + line; } } catch (Exception e) { e.fillInStackTrace(); Log.e("Process Manager", "Unable to execute top command"); } return result; }
결과
02-25 16:29:56.136 I 18646 18646 test : USER PID PPID VSIZE RSS WCHAN PC NAME 02-25 16:29:56.136 I 18646 18646 test : root 1 0 4032 620 ffffffff 00000000 S /init ... 02-25 16:29:56.381 I 18646 18646 test : system 19313 2889 1833472 25764 ffffffff 00000000 R com.sec.pcw.device 02-25 16:29:56.381 I 18646 18646 test : u0_a12 19622 2889 1863360 27464 ffffffff 00000000 S com.google.android.gms.wearable 02-25 16:29:56.386 I 18646 18646 test : root 20149 2 0 0 ffffffff 00000000 S kbase_event 02-25 16:29:56.386 I 18646 18646 test : u0_a182 20337 2889 1835892 26344 ffffffff 00000000 S com.android.exchange 02-25 16:29:56.386 I 18646 18646 test : root 23503 2 0 0 ffffffff 00000000 S kworker/u16:5 02-25 16:29:56.386 I 18646 18646 test : root 23507 2 0 0 ffffffff 00000000 S kworker/u16:7 02-25 16:29:56.391 I 18646 18646 test : u0_a83 24002 2889 1862944 27940 ffffffff 00000000 S com.samsung.android.allshare.service.mediashare 02-25 16:29:56.391 I 18646 18646 test : root 29279 2 0 0 ffffffff 00000000 S kworker/4:3 02-25 16:29:56.391 I 18646 18646 test : root 32212 2 0 0 ffffffff 00000000 S kworker/u17:0
댓글 없음:
댓글 쓰기