From 0a30328c10367f57834d7e8597832b6af00f5240 Mon Sep 17 00:00:00 2001 From: Kristian Monsen Date: Fri, 18 Jan 2013 14:50:07 -0800 Subject: Better detecting if current threasd is main thread Old approach got broken after: https://googleplex-android-review.googlesource.com/#/c/266421/2 Change-Id: I12ae23efdbaebd8ba24acb1b7eff75c912d24f1d --- .../src/com/android/browserpowertest/PowerTestActivity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/BrowserPowerTest') diff --git a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java index 1b72486..ab60f21 100644 --- a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java +++ b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java @@ -21,6 +21,7 @@ import android.app.ActivityThread; import android.graphics.Bitmap; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.util.Log; import android.view.ViewGroup; @@ -180,7 +181,7 @@ public class PowerTestActivity extends Activity { } private final void validateNotAppThread() { - if (ActivityThread.currentActivityThread() != null) { + if (Looper.myLooper() == Looper.getMainLooper()) { throw new RuntimeException( "This method can not be called from the main application thread"); } -- cgit v1.1