summaryrefslogtreecommitdiffstats
path: root/apps/Development/src/com/android/development/BadBehaviorActivity.java
diff options
context:
space:
mode:
Diffstat (limited to 'apps/Development/src/com/android/development/BadBehaviorActivity.java')
-rw-r--r--apps/Development/src/com/android/development/BadBehaviorActivity.java76
1 files changed, 68 insertions, 8 deletions
diff --git a/apps/Development/src/com/android/development/BadBehaviorActivity.java b/apps/Development/src/com/android/development/BadBehaviorActivity.java
index d3974560d..aede60b9c 100644
--- a/apps/Development/src/com/android/development/BadBehaviorActivity.java
+++ b/apps/Development/src/com/android/development/BadBehaviorActivity.java
@@ -17,6 +17,11 @@
package com.android.development;
import android.app.Activity;
+import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IBinder;
import android.os.IPowerManager;
@@ -27,16 +32,49 @@ import android.view.View;
import android.widget.Button;
public class BadBehaviorActivity extends Activity {
- static class BadBehaviorException extends RuntimeException {
+ private static final String TAG = "BadBehaviorActivity";
+
+ private static class BadBehaviorException extends RuntimeException {
BadBehaviorException() {
super("Whatcha gonna do, whatcha gonna do",
new IllegalStateException("When they come for you"));
}
}
+ public static class BadReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.i(TAG, "in BadReceiver.onReceive() -- about to hang");
+ try { Thread.sleep(20000); } catch (InterruptedException e) { Log.wtf(TAG, e); }
+ }
+ };
+
+ public static class BadService extends Service {
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ @Override
+ public int onStartCommand(Intent intent, int flags, int id) {
+ Log.i(TAG, "in BadService.onStartCommand() -- about to hang");
+ try { Thread.sleep(30000); } catch (InterruptedException e) { Log.wtf(TAG, e); }
+ stopSelf();
+ return START_NOT_STICKY;
+ }
+ }
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(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); }
+ finish();
+ return;
+ }
+
setContentView(R.layout.bad_behavior);
Button crash_system = (Button) findViewById(R.id.bad_behavior_crash_system);
@@ -47,7 +85,7 @@ public class BadBehaviorActivity extends Activity {
IPowerManager pm = IPowerManager.Stub.asInterface(b);
pm.crash("Crashed by BadBehaviorActivity");
} catch (RemoteException e) {
- Log.e("BadBehavior", "Can't call IPowerManager.crash()", e);
+ Log.e(TAG, "Can't call IPowerManager.crash()", e);
}
}
});
@@ -69,17 +107,39 @@ public class BadBehaviorActivity extends Activity {
Button wtf = (Button) findViewById(R.id.bad_behavior_wtf);
wtf.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) { Log.wtf("BadBehavior", "Apps Behaving Badly"); }
+ public void onClick(View v) { Log.wtf(TAG, "Apps Behaving Badly"); }
});
Button anr = (Button) findViewById(R.id.bad_behavior_anr);
anr.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
- try {
- Thread.sleep(20000);
- } catch (InterruptedException e) {
- throw new IllegalStateException(e);
- }
+ Log.i(TAG, "ANR pressed -- about to hang");
+ try { Thread.sleep(20000); } catch (InterruptedException e) { Log.wtf(TAG, e); }
+ }
+ });
+
+ Button anr_activity = (Button) findViewById(R.id.bad_behavior_anr_activity);
+ anr_activity.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Intent intent = new Intent(BadBehaviorActivity.this, BadBehaviorActivity.class);
+ Log.i(TAG, "ANR activity pressed -- about to launch");
+ startActivity(intent.putExtra("anr", true));
+ }
+ });
+
+ Button anr_broadcast = (Button) findViewById(R.id.bad_behavior_anr_broadcast);
+ anr_broadcast.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Log.i(TAG, "ANR broadcast pressed -- about to send");
+ sendOrderedBroadcast(new Intent("com.android.development.BAD_BEHAVIOR"), null);
+ }
+ });
+
+ Button anr_service = (Button) findViewById(R.id.bad_behavior_anr_service);
+ anr_service.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Log.i(TAG, "ANR service pressed -- about to start");
+ startService(new Intent(BadBehaviorActivity.this, BadService.class));
}
});
}