diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml
index 3c75a635884..1b33226fcae 100644
--- a/apps/Development/AndroidManifest.xml
+++ b/apps/Development/AndroidManifest.xml
@@ -28,6 +28,7 @@
+
diff --git a/apps/Development/res/layout/bad_behavior.xml b/apps/Development/res/layout/bad_behavior.xml
index abd863f3ddf..ce10ebba566 100644
--- a/apps/Development/res/layout/bad_behavior.xml
+++ b/apps/Development/res/layout/bad_behavior.xml
@@ -14,54 +14,70 @@
limitations under the License.
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml
index b1310f49730..c28ae6de5f9 100644
--- a/apps/Development/res/values/strings.xml
+++ b/apps/Development/res/values/strings.xml
@@ -196,13 +196,15 @@
Select account to sync
- Crash the system server
Crash the main app thread
Crash an auxiliary app thread
Crash the native process
+ Crash the system server
Report a WTF condition
ANR (Stop responding for 20 seconds)
- ANR launching a new Activity
+ ANR starting an Activity
ANR receiving a broadcast Intent
ANR starting a Service
+ System ANR (in ActivityManager)
+ Wedge system (5 minute system ANR)
diff --git a/apps/Development/src/com/android/development/BadBehaviorActivity.java b/apps/Development/src/com/android/development/BadBehaviorActivity.java
index d559fbc2ad8..4e06ae9d27b 100644
--- a/apps/Development/src/com/android/development/BadBehaviorActivity.java
+++ b/apps/Development/src/com/android/development/BadBehaviorActivity.java
@@ -17,6 +17,9 @@
package com.android.development;
import android.app.Activity;
+import android.app.ActivityManagerNative;
+import android.app.IActivityController;
+import android.app.IActivityManager;
import android.app.Service;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -45,8 +48,9 @@ private static class BadBehaviorException extends RuntimeException {
public static class BadReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
- Log.i(TAG, "in BadReceiver.onReceive() -- about to hang");
+ Log.i(TAG, "in broadcast receiver -- about to hang");
try { Thread.sleep(20000); } catch (InterruptedException e) { Log.wtf(TAG, e); }
+ Log.i(TAG, "broadcast receiver hang finished -- returning");
}
};
@@ -58,13 +62,49 @@ public IBinder onBind(Intent intent) {
@Override
public int onStartCommand(Intent intent, int flags, int id) {
- Log.i(TAG, "in BadService.onStartCommand() -- about to hang");
+ Log.i(TAG, "in service start -- about to hang");
try { Thread.sleep(30000); } catch (InterruptedException e) { Log.wtf(TAG, e); }
+ Log.i(TAG, "service hang finished -- stopping and returning");
stopSelf();
return START_NOT_STICKY;
}
}
+ public static class BadController extends IActivityController.Stub {
+ private int mDelay;
+
+ public BadController(int delay) { mDelay = delay; }
+
+ public boolean activityStarting(Intent intent, String pkg) {
+ try {
+ ActivityManagerNative.getDefault().setActivityController(null);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Can't call IActivityManager.setActivityController", e);
+ }
+
+ if (mDelay > 0) {
+ Log.i(TAG, "in activity controller -- about to hang");
+ try { Thread.sleep(mDelay); } catch (InterruptedException e) { Log.wtf(TAG, e); }
+ Log.i(TAG, "activity controller hang finished -- disabling and returning");
+ mDelay = 0;
+ }
+
+ return true;
+ }
+
+ public boolean activityResuming(String pkg) {
+ return true;
+ }
+
+ public boolean appCrashed(String proc, int pid, String m, String m2, long time, String st) {
+ return true;
+ }
+
+ public int appNotResponding(String proc, int pid, String st) {
+ return 0;
+ }
+ }
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -72,6 +112,13 @@ public void onCreate(Bundle icicle) {
if (getIntent().getBooleanExtra("anr", false)) {
Log.i(TAG, "in ANR activity -- about to hang");
try { Thread.sleep(20000); } catch (InterruptedException e) { Log.wtf(TAG, e); }
+ Log.i(TAG, "activity hang finished -- finishing");
+ finish();
+ return;
+ }
+
+ if (getIntent().getBooleanExtra("dummy", false)) {
+ Log.i(TAG, "in dummy activity -- finishing");
finish();
return;
}
@@ -127,6 +174,7 @@ public void onClick(View v) {
public void onClick(View v) {
Log.i(TAG, "ANR pressed -- about to hang");
try { Thread.sleep(20000); } catch (InterruptedException e) { Log.wtf(TAG, e); }
+ Log.i(TAG, "hang finished -- returning");
}
});
@@ -154,5 +202,35 @@ public void onClick(View v) {
startService(new Intent(BadBehaviorActivity.this, BadService.class));
}
});
+
+ Button anr_system = (Button) findViewById(R.id.bad_behavior_anr_system);
+ anr_system.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Intent intent = new Intent(BadBehaviorActivity.this, BadBehaviorActivity.class);
+ Log.i(TAG, "ANR system pressed -- about to engage");
+ try {
+ ActivityManagerNative.getDefault().setActivityController(
+ new BadController(20000));
+ } catch (RemoteException e) {
+ Log.e(TAG, "Can't call IActivityManager.setActivityController", e);
+ }
+ startActivity(intent.putExtra("dummy", true));
+ }
+ });
+
+ Button wedge_system = (Button) findViewById(R.id.bad_behavior_wedge_system);
+ wedge_system.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Intent intent = new Intent(BadBehaviorActivity.this, BadBehaviorActivity.class);
+ Log.i(TAG, "Wedge system pressed -- about to engage");
+ try {
+ ActivityManagerNative.getDefault().setActivityController(
+ new BadController(300000));
+ } catch (RemoteException e) {
+ Log.e(TAG, "Can't call IActivityManager.setActivityController", e);
+ }
+ startActivity(intent.putExtra("dummy", true));
+ }
+ });
}
}