Skip to content

Commit 450a135

Browse files
egnorAndroid (Google) Code Review
authored andcommitted
Merge "Add a native crash facility to Bad Behavior."
2 parents af94291 + 4903dae commit 450a135

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

apps/Development/res/layout/bad_behavior.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
android:layout_height="wrap_content"
3535
android:text="@string/bad_behavior_crash_thread_label" />
3636

37+
<Button android:id="@+id/bad_behavior_crash_native"
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content"
40+
android:text="@string/bad_behavior_crash_native_label" />
41+
3742
<Button android:id="@+id/bad_behavior_wtf"
3843
android:layout_width="wrap_content"
3944
android:layout_height="wrap_content"

apps/Development/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
<string name="bad_behavior_crash_system_label">Crash the system server</string>
200200
<string name="bad_behavior_crash_main_label">Crash the main app thread</string>
201201
<string name="bad_behavior_crash_thread_label">Crash an auxiliary app thread</string>
202+
<string name="bad_behavior_crash_native_label">Crash the native process</string>
202203
<string name="bad_behavior_wtf_label">Report a WTF condition</string>
203204
<string name="bad_behavior_anr_label">ANR (Stop responding for 20 seconds)</string>
204205
<string name="bad_behavior_anr_activity_label">ANR launching a new Activity</string>

apps/Development/src/com/android/development/BadBehaviorActivity.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import android.os.Bundle;
2626
import android.os.IBinder;
2727
import android.os.IPowerManager;
28+
import android.os.Process;
2829
import android.os.RemoteException;
2930
import android.os.ServiceManager;
3031
import android.util.Log;
@@ -105,6 +106,17 @@ public void onClick(View v) {
105106
}
106107
});
107108

109+
Button crash_native = (Button) findViewById(R.id.bad_behavior_crash_native);
110+
crash_native.setOnClickListener(new View.OnClickListener() {
111+
public void onClick(View v) {
112+
// For some reason, the JVM needs two of these to get the hint
113+
Log.i(TAG, "Native crash pressed -- about to kill -11 self");
114+
Process.sendSignal(Process.myPid(), 11);
115+
Process.sendSignal(Process.myPid(), 11);
116+
Log.i(TAG, "Finished kill -11, should be dead or dying");
117+
}
118+
});
119+
108120
Button wtf = (Button) findViewById(R.id.bad_behavior_wtf);
109121
wtf.setOnClickListener(new View.OnClickListener() {
110122
public void onClick(View v) { Log.wtf(TAG, "Apps Behaving Badly"); }

0 commit comments

Comments
 (0)