diff options
| author | 2013-01-18 23:57:47 +0000 | |
|---|---|---|
| committer | 2013-01-18 23:58:33 +0000 | |
| commit | 21af9258f37dd9ea9e9ae66ce609d104faac48d6 (patch) | |
| tree | 6e704c5e4b8c4bf322b25c281c76595e9c8aaa56 | |
| parent | 70b900cded1e8b5955509630ac6370688a3481cb (diff) | |
| parent | 0a30328c10367f57834d7e8597832b6af00f5240 (diff) | |
Merge "Better detecting if current threasd is main thread"
3 files changed, 6 insertions, 3 deletions
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java index e0856aeaee03..39186c654aae 100644 --- a/core/java/android/app/Instrumentation.java +++ b/core/java/android/app/Instrumentation.java @@ -27,6 +27,7 @@ import android.hardware.input.InputManager; import android.os.Bundle; import android.os.Debug; import android.os.IBinder; +import android.os.Looper; import android.os.MessageQueue; import android.os.PerformanceCollector; import android.os.Process; @@ -1637,7 +1638,7 @@ public class Instrumentation { } 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"); } diff --git a/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java b/tests/BrowserPowerTest/src/com/android/browserpowertest/PowerTestActivity.java index 1b72486a075b..ab60f21a610b 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"); } diff --git a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java index 9a4e99ea7bda..22b587fe98e6 100644 --- a/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java +++ b/tests/DumpRenderTree/src/com/android/dumprendertree/ReliabilityTestActivity.java @@ -22,6 +22,7 @@ import android.graphics.Bitmap; import android.net.http.SslError; import android.os.Bundle; import android.os.Handler; +import android.os.Looper; import android.os.Message; import android.util.Log; import android.view.ViewGroup; @@ -184,7 +185,7 @@ public class ReliabilityTestActivity 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"); } |