Add a native crash facility to Bad Behavior.

This commit is contained in:
Dan Egnor
2010-01-27 15:10:58 -08:00
parent 2086587ba4
commit 4903dae035
3 changed files with 18 additions and 0 deletions

View File

@@ -34,6 +34,11 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/bad_behavior_crash_thread_label" /> android:text="@string/bad_behavior_crash_thread_label" />
<Button android:id="@+id/bad_behavior_crash_native"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/bad_behavior_crash_native_label" />
<Button android:id="@+id/bad_behavior_wtf" <Button android:id="@+id/bad_behavior_wtf"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@@ -199,6 +199,7 @@
<string name="bad_behavior_crash_system_label">Crash the system server</string> <string name="bad_behavior_crash_system_label">Crash the system server</string>
<string name="bad_behavior_crash_main_label">Crash the main app thread</string> <string name="bad_behavior_crash_main_label">Crash the main app thread</string>
<string name="bad_behavior_crash_thread_label">Crash an auxiliary app thread</string> <string name="bad_behavior_crash_thread_label">Crash an auxiliary app thread</string>
<string name="bad_behavior_crash_native_label">Crash the native process</string>
<string name="bad_behavior_wtf_label">Report a WTF condition</string> <string name="bad_behavior_wtf_label">Report a WTF condition</string>
<string name="bad_behavior_anr_label">ANR (Stop responding for 20 seconds)</string> <string name="bad_behavior_anr_label">ANR (Stop responding for 20 seconds)</string>
<string name="bad_behavior_anr_activity_label">ANR launching a new Activity</string> <string name="bad_behavior_anr_activity_label">ANR launching a new Activity</string>

View File

@@ -25,6 +25,7 @@ import android.content.IntentFilter;
import android.os.Bundle; import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.IPowerManager; import android.os.IPowerManager;
import android.os.Process;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.ServiceManager; import android.os.ServiceManager;
import android.util.Log; import android.util.Log;
@@ -105,6 +106,17 @@ public class BadBehaviorActivity extends Activity {
} }
}); });
Button crash_native = (Button) findViewById(R.id.bad_behavior_crash_native);
crash_native.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// For some reason, the JVM needs two of these to get the hint
Log.i(TAG, "Native crash pressed -- about to kill -11 self");
Process.sendSignal(Process.myPid(), 11);
Process.sendSignal(Process.myPid(), 11);
Log.i(TAG, "Finished kill -11, should be dead or dying");
}
});
Button wtf = (Button) findViewById(R.id.bad_behavior_wtf); Button wtf = (Button) findViewById(R.id.bad_behavior_wtf);
wtf.setOnClickListener(new View.OnClickListener() { wtf.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) { Log.wtf(TAG, "Apps Behaving Badly"); } public void onClick(View v) { Log.wtf(TAG, "Apps Behaving Badly"); }