summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoe Onorato <joeo@google.com>2016-04-20 15:43:17 -0700
committerJoe Onorato <joeo@google.com>2016-04-20 15:44:02 -0700
commit795b4074602dea982b6ca6869830352eeeda6f20 (patch)
treeb5444b50cc775afb0ab62f1a87d8a310d3942f10 /apps
parent6da7e3f8c4691fbd1642b4657f714ae43c3e462c (diff)
downloadandroid_development-795b4074602dea982b6ca6869830352eeeda6f20.tar.gz
android_development-795b4074602dea982b6ca6869830352eeeda6f20.tar.bz2
android_development-795b4074602dea982b6ca6869830352eeeda6f20.zip
Add exponential broadcast flood to the BadBehaviorActivity.
Bug: 28196243 Change-Id: I26eb8d5f7f9bcc90bfe5aa52f3d61a44b6105006
Diffstat (limited to 'apps')
-rw-r--r--apps/Development/res/layout/bad_behavior.xml5
-rw-r--r--apps/Development/res/values/strings.xml1
-rw-r--r--apps/Development/src/com/android/development/BadBehaviorActivity.java40
3 files changed, 46 insertions, 0 deletions
diff --git a/apps/Development/res/layout/bad_behavior.xml b/apps/Development/res/layout/bad_behavior.xml
index 6415da679..47139ddd9 100644
--- a/apps/Development/res/layout/bad_behavior.xml
+++ b/apps/Development/res/layout/bad_behavior.xml
@@ -78,6 +78,11 @@
android:layout_height="wrap_content"
android:text="@string/bad_behavior_wedge_system_label" />
+ <Button android:id="@+id/bad_behavior_broadcast_flood"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:text="@string/bad_behavior_broadcast_flood" />
+
</LinearLayout>
</ScrollView>
diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml
index d8e7eeabe..5f96d24e7 100644
--- a/apps/Development/res/values/strings.xml
+++ b/apps/Development/res/values/strings.xml
@@ -229,6 +229,7 @@
<string name="bad_behavior_anr_service_label">ANR starting a Service</string>
<string name="bad_behavior_anr_system_label">System ANR (in ActivityManager)</string>
<string name="bad_behavior_wedge_system_label">Wedge system (5 minute system ANR)</string>
+ <string name="bad_behavior_broadcast_flood">Flood the system with broadcasts</string>
<!-- CacheAbuser -->
<string name="cache_abuser_start_internal_abuse">Quickly abuse internal cache</string>
diff --git a/apps/Development/src/com/android/development/BadBehaviorActivity.java b/apps/Development/src/com/android/development/BadBehaviorActivity.java
index e33c758de..9cce3fdb5 100644
--- a/apps/Development/src/com/android/development/BadBehaviorActivity.java
+++ b/apps/Development/src/com/android/development/BadBehaviorActivity.java
@@ -26,6 +26,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
+import android.os.Handler;
import android.os.IBinder;
import android.os.IPowerManager;
import android.os.Process;
@@ -38,6 +39,10 @@ import android.widget.Button;
public class BadBehaviorActivity extends Activity {
private static final String TAG = "BadBehaviorActivity";
+ private static final String BROADCAST_FLOOD = "com.android.development.BROADCAST_FLOOD";
+
+ private Handler mHandler = new Handler();
+
private static class BadBehaviorException extends RuntimeException {
BadBehaviorException() {
super("Whatcha gonna do, whatcha gonna do",
@@ -113,6 +118,25 @@ public class BadBehaviorActivity extends Activity {
}
}
+ int mFloodBroadcastsSent;
+ int mFloodBroadcastsReceived;
+
+ public class ExponentialReceiver extends BroadcastReceiver {
+ String name;
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final int N = 5;
+ mFloodBroadcastsReceived++;
+ for (int i=0; i<N; i++) {
+ mFloodBroadcastsSent++;
+ Log.i(TAG, this.name + " sent=" + mFloodBroadcastsSent
+ + " received=" + mFloodBroadcastsReceived);
+ context.sendBroadcast(new Intent(BROADCAST_FLOOD));
+ }
+ }
+ };
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@@ -240,5 +264,21 @@ public class BadBehaviorActivity extends Activity {
startActivity(intent.putExtra("dummy", true));
}
});
+
+ Button broadcast_flood = (Button) findViewById(R.id.bad_behavior_broadcast_flood);
+ broadcast_flood.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ // Let's create and register some broadcast receivers
+ IntentFilter filter = new IntentFilter(BROADCAST_FLOOD);
+ for (int i=0; i<30; i++) {
+ ExponentialReceiver receiver = new ExponentialReceiver();
+ receiver.name = "ExponentialReceiver " + i;
+ registerReceiver(receiver, filter);
+ }
+ // Now open the floodgates
+ mFloodBroadcastsSent = 1;
+ sendBroadcast(new Intent(BROADCAST_FLOOD));
+ }
+ });
}
}