diff options
author | Maksymilian Osowski <maxosowski@google.com> | 2010-09-17 15:10:18 +0100 |
---|---|---|
committer | Maksymilian Osowski <maxosowski@google.com> | 2010-09-17 15:11:15 +0100 |
commit | 9893d96d1231235f3d984e9dc751f08409a5f873 (patch) | |
tree | 38273a85d3d8e0a17cedb195076babcdae2ca9ba /tests/DumpRenderTree2 | |
parent | b6a2364ebad11596858892fa9806346e1c011ad6 (diff) | |
download | frameworks_base-9893d96d1231235f3d984e9dc751f08409a5f873.zip frameworks_base-9893d96d1231235f3d984e9dc751f08409a5f873.tar.gz frameworks_base-9893d96d1231235f3d984e9dc751f08409a5f873.tar.bz2 |
Updated ManagerService to call Summarizer.summarize() in a separate thread.
This could potentially take a long time and result in ANR.
Change-Id: Ib8b246e627e841217b68c955d92c97801e93d923
Diffstat (limited to 'tests/DumpRenderTree2')
-rw-r--r-- | tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java | 41 | ||||
-rw-r--r-- | tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java | 4 |
2 files changed, 30 insertions, 15 deletions
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java index 9caabdb..d4bb0d38 100644 --- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java +++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/ManagerService.java @@ -39,6 +39,7 @@ public class ManagerService extends Service { private static final String LOG_TAG = "ManagerService"; private static final int MSG_CRASH_TIMEOUT_EXPIRED = 0; + private static final int MSG_SUMMARIZER_DONE = 1; private static final int CRASH_TIMEOUT_MS = 20 * 1000; @@ -86,30 +87,42 @@ public class ManagerService extends Service { break; case MSG_CURRENT_TEST_CRASHED: - mCrashMessagesHandler.removeMessages(MSG_CRASH_TIMEOUT_EXPIRED); + mInternalMessagesHandler.removeMessages(MSG_CRASH_TIMEOUT_EXPIRED); onTestCrashed(); break; case MSG_ALL_TESTS_FINISHED: - mSummarizer.setTestsRelativePath(mAllTestsRelativePath); - mSummarizer.summarize(); - Intent intent = new Intent(ManagerService.this, TestsListActivity.class); - intent.setAction(Intent.ACTION_SHUTDOWN); - /** This flag is needed because we send the intent from the service */ - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - break; + /** We run it in a separate thread to avoid ANR */ + new Thread() { + @Override + public void run() { + mSummarizer.setTestsRelativePath(mAllTestsRelativePath); + Message msg = Message.obtain(mInternalMessagesHandler, + MSG_SUMMARIZER_DONE); + mSummarizer.summarize(msg); + } + }.start(); } } }; private Messenger mMessenger = new Messenger(mIncomingHandler); - private Handler mCrashMessagesHandler = new Handler() { + private Handler mInternalMessagesHandler = new Handler() { @Override public void handleMessage(Message msg) { - if (msg.what == MSG_CRASH_TIMEOUT_EXPIRED) { - onTestCrashed(); + switch (msg.what) { + case MSG_CRASH_TIMEOUT_EXPIRED: + onTestCrashed(); + break; + + case MSG_SUMMARIZER_DONE: + Intent intent = new Intent(ManagerService.this, TestsListActivity.class); + intent.setAction(Intent.ACTION_SHUTDOWN); + /** This flag is needed because we send the intent from the service */ + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); + break; } } }; @@ -150,7 +163,7 @@ public class ManagerService extends Service { } private void onActualResultsObtained(Bundle bundle) { - mCrashMessagesHandler.removeMessages(MSG_CRASH_TIMEOUT_EXPIRED); + mInternalMessagesHandler.removeMessages(MSG_CRASH_TIMEOUT_EXPIRED); ensureNextTestSetup(bundle.getString("nextTest"), bundle.getInt("testIndex") + 1); AbstractResult results = @@ -168,7 +181,7 @@ public class ManagerService extends Service { mCurrentlyRunningTest = nextTest; mCurrentlyRunningTestIndex = index; - mCrashMessagesHandler.sendEmptyMessageDelayed(MSG_CRASH_TIMEOUT_EXPIRED, CRASH_TIMEOUT_MS); + mInternalMessagesHandler.sendEmptyMessageDelayed(MSG_CRASH_TIMEOUT_EXPIRED, CRASH_TIMEOUT_MS); } /** diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java index b1dea6e..5dc0f03 100644 --- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java +++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/Summarizer.java @@ -20,6 +20,7 @@ import android.content.res.AssetManager; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; +import android.os.Message; import android.util.DisplayMetrics; import android.util.Log; @@ -234,10 +235,11 @@ public class Summarizer { mTestsRelativePath = testsRelativePath; } - public void summarize() { + public void summarize(Message onFinishMessage) { String webKitRevision = getWebKitRevision(); createHtmlDetails(webKitRevision); createTxtSummary(webKitRevision); + onFinishMessage.sendToTarget(); } public void reset() { |