Okay, been working on Android program and since its JAVA based, I figured this might be a place to get some good advice.
I have been writing this program to run tcpdump, but for some reason it freezes and crashes. I am able to execute the shell commands, but after executing them, the app freezes and crashes.
I am able to get the output, of the shell command, so it does work, but I can't seem to track down what is causing it to crash. Here is the function that is causing the app to crash.
public String tcpdumprun(String FIN_PASSED_CMD){
try {
// Executes the command.
process = Runtime.getRuntime().exec(new String[] {"su", "-c", "/data/tcpdump -vv -s 0 -w /sdcard/dump.txt"});
// Reads stdout.
// NOTE: You can write to stdin of the command using
// process.getOutputStream().
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
// Waits for the command to finish.
process.waitFor();
return output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
The passes argument is not being used currently while I test the functionality.
Also, here is the log cat output when it crashes.
D/StatusBarService(20454): updateIcon slot=phone_signal index=20 viewIndex=14 ol
d=StatusBarIcon(pkg=com.android.systemui id=0x7f020011 level=0 visible=true num=
0 ) icon=StatusBarIcon(pkg=com.android.systemui id=0x7f020012 level=0 visible=tr
ue num=0 )
E/su ( 9326): sudb - Opening database
E/su ( 9326): sudb - Database opened
E/su ( 9326): sudb - Database closed
D/su ( 9326): 10121 com.dumpin.tcpdump executing 0 /data/tcpdump -vv -s 0 -
w /sdcard/dump.txt using shell /system/bin/sh : sh
D/Database( 9288): dbopen(): path = /data/data/com.noshufou.android.su/databases
/su.db, flag = 6, file size = 11264
I/Database( 9288): sqlite returned: error code = 0, msg = Recovered 12 frames fr
om WAL file /data/data/com.noshufou.android.su/databases/su.db-wal
D/Database( 9288): dbopen(): path = /data/data/com.noshufou.android.su/databases
/su.db, mode: wal, disk free size: 97 M, handle: 0x33f5d0
W/ActivityManager( 459): Unable to start service Intent { (has extras) }: not f
ound
I/ActivityManager( 459): Process com.htc.sdm (pid 8905) has died.
D/skia (18663): purging 232K from font cache [28 entries]
D/dalvikvm(18663): GC_EXPLICIT freed 660K, 51% free 4479K/8967K, external 19151K
/21199K, paused 214ms
D/dalvikvm(20557): GC_EXPLICIT freed 5K, 50% free 2718K/5379K, external 0K/0K, p
aused 68ms
D/StatusBarPolicy(20454): onSignalStrengthsChanged
D/StatusBarPolicy(20454): iconIndex=1
V/StatusBarPolicy(20454): cdmaLevel:2;max:6
D/StatusBarPolicy(20454): iconLevel:2
D/StatusBarService(20454): updateIcon slot=phone_signal index=20 viewIndex=14 ol
d=StatusBarIcon(pkg=com.android.systemui id=0x7f020012 level=0 visible=true num=
0 ) icon=StatusBarIcon(pkg=com.android.systemui id=0x7f020011 level=0 visible=tr
ue num=0 )
D/StatusBarPolicy(20454): onDataActivity directtion=4
D/StatusBarPolicy(20454): hasService()=true ,mDataState=2 ,mPhone.htcModemLinkOn
()=false ,mDataActivity=4
D/StatusBarPolicy(20454): slotType[0]=SIM
D/StatusBarService(20454): updateIcon slot=data_connection index=18 viewIndex=13
old=StatusBarIcon(pkg=com.android.systemui id=0x7f020018 level=0 visible=true n
um=0 ) icon=StatusBarIcon(pkg=com.android.systemui id=0x7f02001c level=0 visible
=true num=0 )
D/dalvikvm( 8581): GC_EXPLICIT freed 224K, 50% free 2792K/5511K, external 0K/0K,
paused 92ms
I/ConnLib ( 6703): Enter network idle mode
D/StatusBarPolicy(20454): onSignalStrengthsChanged
D/StatusBarPolicy(20454): iconIndex=1
V/StatusBarPolicy(20454): cdmaLevel:3;max:6
D/StatusBarPolicy(20454): iconLevel:3
D/StatusBarService(20454): updateIcon slot=phone_signal index=20 viewIndex=14 ol
d=StatusBarIcon(pkg=com.android.systemui id=0x7f020011 level=0 visible=true num=
0 ) icon=StatusBarIcon(pkg=com.android.systemui id=0x7f020012 level=0 visible=tr
ue num=0 )
I/ConnLib ( 6703): Enter network idle mode
D/StatusBarPolicy(20454): onSignalStrengthsChanged
D/StatusBarPolicy(20454): iconIndex=1
V/StatusBarPolicy(20454): cdmaLevel:3;max:6
D/StatusBarPolicy(20454): iconLevel:3
D/StatusBarService(20454): updateIcon slot=phone_signal index=20 viewIndex=14 ol
d=StatusBarIcon(pkg=com.android.systemui id=0x7f020012 level=0 visible=true num=
0 ) icon=StatusBarIcon(pkg=com.android.systemui id=0x7f020012 level=0 visible=tr
ue num=0 )
D/StatusBarPolicy(20454): onSignalStrengthsChanged
D/StatusBarPolicy(20454): iconIndex=1
V/StatusBarPolicy(20454): cdmaLevel:3;max:6
D/StatusBarPolicy(20454): iconLevel:3
D/StatusBarService(20454): updateIcon slot=phone_signal index=20 viewIndex=14 ol
d=StatusBarIcon(pkg=com.android.systemui id=0x7f020012 level=0 visible=true num=
0 ) icon=StatusBarIcon(pkg=com.android.systemui id=0x7f020012 level=0 visible=tr
ue num=0 )
D/dalvikvm(20623): GC_EXPLICIT freed 150K, 47% free 4487K/8327K, external 381K/8
12K, paused 143ms
D/dalvikvm( 8139): GC_EXPLICIT freed 74K, 49% free 2852K/5575K, external 0K/0K,
paused 69ms
I/InputDispatcher( 459): Application is not responding: Window{40904a10 com.lus
kbo.tcpdump/com.dumpin.tcpdump.TcpdumpActivity paused=false}. 15016.1ms since e
vent, 15016.0ms since wait started
I/WindowManager( 459): Input event dispatching timed out sending to com.dumpin.
tcpdump/com.dumpin.tcpdump.TcpdumpActivity
I/Process ( 459): Sending signal. PID: 9275 SIG: 3
I/dalvikvm( 9275): threadid=4: reacting to signal 3
I/dalvikvm( 9275): Wrote stack traces to '/data/anr/traces.txt'
I/Process ( 459): Sending signal. PID: 459 SIG: 3
I/dalvikvm( 459): threadid=4: reacting to signal 3
I/dalvikvm( 459): Wrote stack traces to '/data/anr/traces.txt'
I/Process ( 459): Sending signal. PID: 839 SIG: 3
I/dalvikvm( 839): threadid=4: reacting to signal 3
I/dalvikvm( 839): Wrote stack traces to '/data/anr/traces.txt'
I/Process ( 459): Sending signal. PID: 834 SIG: 3
I/dalvikvm( 834): threadid=4: reacting to signal 3
I/dalvikvm( 834): Wrote stack traces to '/data/anr/traces.txt'
I/Process ( 459): Sending signal. PID: 20454 SIG: 3
I/dalvikvm(20454): threadid=4: reacting to signal 3
I/dalvikvm(20454): Wrote stack traces to '/data/anr/traces.txt'
D/dalvikvm( 459): GC_EXPLICIT freed 1448K, 34% free 9308K/13895K, external 5272
K/6584K, paused 133ms
E/ActivityManager( 459): ANR in com.dumpin.tcpdump (com.dumpin.tcpdump/.Tcpdump
Activity), time=41148475
E/ActivityManager( 459): Reason: keyDispatchingTimedOut
E/ActivityManager( 459): Load: 11.65 / 12.26 / 6.53
E/ActivityManager( 459): CPU usage from 15305ms to -1ms ago:
E/ActivityManager( 459): 3.3% 459/system_server: 1% user + 2.2% kernel / faul
ts: 111 minor
E/ActivityManager( 459): 1.6% 20454/com.android.systemui: 1.4% user + 0.1% ke
rnel / faults: 1 minor
E/ActivityManager( 459): 0.9% 176/akmd: 0% user + 0.9% kernel
E/ActivityManager( 459): 0.2% 20623/com.android.mms: 0.1% user + 0% kernel +
0% iowait / faults: 399 minor 4 major
E/ActivityManager( 459): 0.2% 8139/com.keramidas.TitaniumBackup: 0.1% user +
0% kernel + 0% iowait / faults: 313 minor 1 major
E/ActivityManager( 459): 0.1% 5/events/0: 0% user + 0.1% kernel
E/ActivityManager( 459): 0.1% 13/kondemand/0: 0% user + 0.1% kernel
E/ActivityManager( 459): 0% 1//init: 0% user + 0% kernel / faults: 40 minor
E/ActivityManager( 459): 0% 53/usb_mass_storag: 0% user + 0% kernel
E/ActivityManager( 459): 0% 55/atmel_wq: 0% user + 0% kernel
E/ActivityManager( 459): 0% 9135/adbd: 0% user + 0% kernel
E/ActivityManager( 459): 0% 9196/logcat: 0% user + 0% kernel / faults: 33 min
or 1 major
E/ActivityManager( 459): 8.6% TOTAL: 4.5% user + 3.8% kernel + 0.3% iowait
E/ActivityManager( 459): CPU usage from 641ms to 1163ms later:
E/ActivityManager( 459): 22% 459/system_server: 3.7% user + 18% kernel / faul
ts: 30 minor 25 major
E/ActivityManager( 459): 12% 460/HeapWorker: 7.4% user + 5.5% kernel
E/ActivityManager( 459): 7.4% 724/InputDispatcher: 0% user + 7.4% kernel
E/ActivityManager( 459): 3.7% 467/SurfaceFlinger: 0% user + 3.7% kernel
E/ActivityManager( 459): 2.6% 20454/com.android.systemui: 2.6% user + 0% kern
el
E/ActivityManager( 459): 2.6% 20454/ndroid.systemui: 2.6% user + 0% kernel
E/ActivityManager( 459): 1.1% 63/sd-qd: 0% user + 1.1% kernel
E/ActivityManager( 459): 75% TOTAL: 11% user + 17% kernel + 46% iowait
I/InputDispatcher( 459): Dropping event because the pointer is not down.
I/InputDispatcher( 459): Dropping event because the pointer is not down.
W/ActivityManager( 459): Unable to start service Intent { (has extras) }: not f
ound
I/HtcLockScreen3.0( 459): UnlockArc: UpdateTimeUI
V/DeviceStorageMonitorService( 459): freeMemory=101642240
D/DeviceStorageMonitorService( 459): OoO SMS Memory available. SMS_AVAILABLE_TH
RESHOLD == 524288
I/DeviceStorageMonitorService( 459): Posting Message again
W/ActivityManager( 459): Force finishing activity com.dumpin.tcpdump/.Tcpdump
Activity
I/Process ( 459): Sending signal. PID: 9275 SIG: 9
I/ActivityManager( 459): Killing com.dumpin.tcpdump (pid=9275): user's request
W/UsageStats( 459): Failed writing stats to file:/data/system/usagestats/usage-
20120219
W/ActivityManager( 459): Unable to start service Intent { (has extras) }: not f
ound
E/InputDispatcher( 459): channel '40904a10 com.dumpin.tcpdump/com.dumpin.tcpdum
p.TcpdumpActivity (server)' ~ Consumer closed input channel or an error occurred
. events=0x8
E/InputDispatcher( 459): channel '40904a10 com.dumpin.tcpdump/com.dumpin.tcpdum
p.TcpdumpActivity (server)' ~ Channel is unrecoverably broken and will be dispos
ed!
I/ActivityManager( 459): Process com.dumpin.tcpdump (pid 9275) has died.
E/ActivityManager( 459): fail to set top app changed!
I/WindowManager( 459): WIN DEATH: Window{40904a10 com.dumpin.tcpdump/com.dumpin
.tcpdump.TcpdumpActivity paused=true}
Any suggestions would be appreciated.