diff options
author | Dan Egnor <egnor@google.com> | 2009-12-09 16:30:23 -0800 |
---|---|---|
committer | Dan Egnor <egnor@google.com> | 2009-12-11 13:26:46 -0800 |
commit | d0225ee63f305ef59e17f8ad0dc16b2ef5e85af0 (patch) | |
tree | f07dfb3796bd66b95d0e841417ad340106879e17 /apps | |
parent | f2519b444f658d2d7af8f85b0b95d12f32cf8bd2 (diff) | |
download | android_development-d0225ee63f305ef59e17f8ad0dc16b2ef5e85af0.tar.gz android_development-d0225ee63f305ef59e17f8ad0dc16b2ef5e85af0.tar.bz2 android_development-d0225ee63f305ef59e17f8ad0dc16b2ef5e85af0.zip |
Remove the old Dev Tools exception browser (since it relies on
now eliminated checkin database crash storage functionality).
Add a new test app to Dev Tools, "Bad Behavior", which has
buttons to crash and generate an ANR on command.
Update the Monkey to follow changed APIs.
Diffstat (limited to 'apps')
6 files changed, 121 insertions, 238 deletions
diff --git a/apps/Development/AndroidManifest.xml b/apps/Development/AndroidManifest.xml index 31427a59a..07a4213b3 100644 --- a/apps/Development/AndroidManifest.xml +++ b/apps/Development/AndroidManifest.xml @@ -58,13 +58,6 @@ <category android:name="android.intent.category.TEST" /> </intent-filter> </activity> - <activity android:name="ExceptionBrowser" android:label="Exception Browser"> - <intent-filter> - <action android:name="android.intent.action.MAIN" /> - <category android:name="android.intent.category.TEST" /> - </intent-filter> - </activity> - <activity android:name="StacktraceViewer" android:label="Stacktrace Viewer"/> <activity android:name="PackageSummary" android:label="Package Summary"> </activity> <activity android:name="ShowActivity" android:label="Activity"> @@ -128,44 +121,50 @@ </intent-filter> </activity> - <activity android:name="GLSTester" android:label="Google Login Service"> + <activity android:name="GLSTester" android:label="Google Login Service"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.TEST" /> </intent-filter> </activity> - <activity android:name="RunningProcesses" android:label="Running processes"> + <activity android:name="RunningProcesses" android:label="Running processes"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.TEST" /> </intent-filter> </activity> - <activity android:name="ProcessInfo" android:label="Process Information"> + <activity android:name="ProcessInfo" android:label="Process Information"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> - </activity> + </activity> <!-- - <activity android:name="AppHwConfigList" android:label="Applications Hw Configuration"> + <activity android:name="AppHwConfigList" android:label="Applications Hw Configuration"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.TEST" /> </intent-filter> - </activity> + </activity> --> - <activity android:name="AppHwPref" android:label="Applications Hardware Preferences"> + <activity android:name="AppHwPref" android:label="Applications Hardware Preferences"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> - </activity> - <activity android:name="PermissionDetails" android:label="Permission Info"> + </activity> + <activity android:name="PermissionDetails" android:label="Permission Info"> <intent-filter> <action android:name="com.android.development.VIEW_PERMISSION" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> - </activity> + </activity> + <activity android:name="BadBehaviorActivity" android:label="Bad Behavior"> + <intent-filter> + <action android:name="android.intent.action.MAIN" /> + <category android:name="android.intent.category.TEST" /> + </intent-filter> + </activity> </application> </manifest> diff --git a/apps/Development/res/layout/bad_behavior.xml b/apps/Development/res/layout/bad_behavior.xml new file mode 100644 index 000000000..62a724502 --- /dev/null +++ b/apps/Development/res/layout/bad_behavior.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2009 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="fill_parent" + android:layout_height="fill_parent"> + + <Button android:id="@+id/bad_behavior_crash_main" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/bad_behavior_crash_main_label" /> + + <Button android:id="@+id/bad_behavior_crash_thread" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/bad_behavior_crash_thread_label" /> + + <Button android:id="@+id/bad_behavior_anr" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:text="@string/bad_behavior_anr_label" /> + +</LinearLayout> diff --git a/apps/Development/res/values/strings.xml b/apps/Development/res/values/strings.xml index 350f74db7..cb41087f8 100644 --- a/apps/Development/res/values/strings.xml +++ b/apps/Development/res/values/strings.xml @@ -193,4 +193,9 @@ <string name="binding_bind_failed">Bind failed</string> <string name="binding_waiting_for_connection">Waiting for service to be connected...</string> <string name="select_account_to_sync">Select account to sync</string> + + <!-- BadBehaviorActivity --> + <string name="bad_behavior_crash_main_label">Crash the main thread</string> + <string name="bad_behavior_crash_thread_label">Crash an auxiliary thread</string> + <string name="bad_behavior_anr_label">Stop responding for 20 seconds (ANR)</string> </resources> diff --git a/apps/Development/src/com/android/development/BadBehaviorActivity.java b/apps/Development/src/com/android/development/BadBehaviorActivity.java new file mode 100644 index 000000000..b8f47216a --- /dev/null +++ b/apps/Development/src/com/android/development/BadBehaviorActivity.java @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2009 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.development; + +import android.app.Activity; +import android.os.Bundle; +import android.widget.Button; +import android.view.View; + +public class BadBehaviorActivity extends Activity { + static class BadBehaviorException extends RuntimeException { + BadBehaviorException() { + super("Whatcha gonna do, whatcha gonna do", + new IllegalStateException("When they come for you")); + } + } + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + setContentView(R.layout.bad_behavior); + + Button crash_main = (Button) findViewById(R.id.bad_behavior_crash_main); + crash_main.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { throw new BadBehaviorException(); } + }); + + Button crash_thread = (Button) findViewById(R.id.bad_behavior_crash_thread); + crash_thread.setOnClickListener(new View.OnClickListener() { + public void onClick(View v) { + new Thread() { + @Override + public void run() { throw new BadBehaviorException(); } + }.start(); + } + }); + + 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); + } + } + }); + } +} diff --git a/apps/Development/src/com/android/development/ExceptionBrowser.java b/apps/Development/src/com/android/development/ExceptionBrowser.java deleted file mode 100644 index 63270aab5..000000000 --- a/apps/Development/src/com/android/development/ExceptionBrowser.java +++ /dev/null @@ -1,171 +0,0 @@ -/* -** Copyright 2007, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -package com.android.development; - -import android.app.ListActivity; -import android.content.Context; -import android.content.Intent; -import android.database.Cursor; -import android.database.ContentObserver; -import android.database.DataSetObserver; -import android.graphics.Typeface; -import android.os.RemoteException; -import android.os.ServiceManager; -import android.provider.Checkin; -import android.server.data.CrashData; -import android.server.data.ThrowableData; -import android.os.Bundle; -import android.util.Log; -import android.view.Menu; -import android.view.MenuItem; -import android.view.View; -import android.view.ViewGroup; -import android.view.KeyEvent; -import android.widget.*; - -import org.apache.commons.codec.binary.Base64; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; - -/** - * - * - */ -public class ExceptionBrowser extends ListActivity { - /** Logging identifier. */ - private static final String TAG = "ExceptionBrowser"; - - @Override - protected void onCreate(Bundle icicle) { - super.onCreate(icicle); - - Cursor cursor = getContentResolver().query( - Checkin.Crashes.CONTENT_URI, - new String[] { Checkin.Crashes._ID, Checkin.Crashes.DATA }, - null, null, null); - - if (cursor != null) { - startManagingCursor(cursor); - - setListAdapter(new CursorAdapter(this, cursor, true) { - public View newView(Context context, Cursor c, ViewGroup v) { - return new CrashListItem(context); - } - - public void bindView(View view, Context c, Cursor cursor) { - CrashListItem item = (CrashListItem) view; - try { - String data = cursor.getString(1); - CrashData crash = new CrashData( - new DataInputStream( - new ByteArrayInputStream( - Base64.decodeBase64(data.getBytes())))); - - ThrowableData exc = crash.getThrowableData(); - item.setText(exc.getType() + ": " + exc.getMessage()); - item.setCrashData(crash); - } catch (IOException e) { - item.setText("Invalid crash: " + e); - Log.e(TAG, "Invalid crash", e); - } - } - }); - } else { - // No database, no exceptions, empty list. - setListAdapter(new BaseAdapter() { - public int getCount() { - return 0; - } - - public Object getItem(int position) { - throw new AssertionError(); - } - - public long getItemId(int position) { - throw new AssertionError(); - } - - public View getView(int position, View convertView, - ViewGroup parent) { - throw new AssertionError(); - } - }); - } - } - - private static final int UPLOAD_ID = Menu.FIRST; - private static final int CLEAR_ID = Menu.FIRST + 1; - - public boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - - menu.add(0, UPLOAD_ID, 0, R.string.menu_upload_exceptions); - menu.add(0, CLEAR_ID, 0, R.string.menu_clear_exceptions); - - return true; - } - - - @Override - public boolean onOptionsItemSelected(MenuItem item) { - // Handle all of the possible menu actions. - switch (item.getItemId()) { - case UPLOAD_ID: - sendBroadcast(new Intent(Checkin.TriggerIntent.ACTION)); - break; - case CLEAR_ID: - getContentResolver().delete( - Checkin.Crashes.CONTENT_URI, null, null); - break; - } - return super.onOptionsItemSelected(item); - } - - static class CrashListItem extends TextView { - CrashData crashData = null; - - public CrashListItem(Context context) { - super(context); - setTextSize(10); - setTypeface(Typeface.MONOSPACE); - } - - public CrashData getCrashData() { - return crashData; - } - - public void setCrashData(CrashData crashData) { - this.crashData = crashData; - } - } - - @Override - protected void onListItemClick(ListView l, View view, int pos, long id) { - // TODO: Use a generic VIEW action on the crash's content URI. - CrashData crash = ((CrashListItem) view).getCrashData(); - if (crash != null) { - Intent intent = new Intent(); - intent.setClass(this, StacktraceViewer.class); - intent.putExtra( - CrashData.class.getName(), - crash.getThrowableData().toString()); - startActivity(intent); - } - } -} diff --git a/apps/Development/src/com/android/development/StacktraceViewer.java b/apps/Development/src/com/android/development/StacktraceViewer.java deleted file mode 100644 index 96b052129..000000000 --- a/apps/Development/src/com/android/development/StacktraceViewer.java +++ /dev/null @@ -1,50 +0,0 @@ -/* -** Copyright 2007, The Android Open Source Project -** -** Licensed under the Apache License, Version 2.0 (the "License"); -** you may not use this file except in compliance with the License. -** You may obtain a copy of the License at -** -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, -** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** See the License for the specific language governing permissions and -** limitations under the License. -*/ - -package com.android.development; - - -import android.app.Activity; -import android.widget.EditText; -import android.widget.TextView; -import android.text.method.ScrollingMovementMethod; -import android.os.Bundle; -import android.server.data.CrashData; -import android.server.data.ThrowableData; -import android.server.data.StackTraceElementData; -import android.graphics.Typeface; - -/** - * Views a single stack trace. - */ -public class StacktraceViewer extends Activity { - - protected void onCreate(Bundle icicle) { - super.onCreate(icicle); - setContentView(R.layout.log_viewer); - - TextView text = (TextView) findViewById(R.id.text); - text.setTextSize(10); - text.setHorizontallyScrolling(true); - text.setTypeface(Typeface.MONOSPACE); - text.setMovementMethod(ScrollingMovementMethod.getInstance()); - - String stacktrace = getIntent().getExtras().getString( - CrashData.class.getName()); - - text.setText(stacktrace); - } -} |