diff options
Diffstat (limited to 'common/src/com/android/tv/common/TvCommonUtils.java')
-rw-r--r-- | common/src/com/android/tv/common/TvCommonUtils.java | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/common/src/com/android/tv/common/TvCommonUtils.java b/common/src/com/android/tv/common/TvCommonUtils.java index a88dd3a8..c391ad24 100644 --- a/common/src/com/android/tv/common/TvCommonUtils.java +++ b/common/src/com/android/tv/common/TvCommonUtils.java @@ -23,6 +23,8 @@ import android.media.tv.TvInputInfo; * Util class for common use in TV app and inputs. */ public final class TvCommonUtils { + private static Boolean sRunningInTest; + private TvCommonUtils() { } /** @@ -58,12 +60,15 @@ public final class TvCommonUtils { * the usual devices even the application is running in tests. We need to figure it out by * checking whether the class in tv-tests-common module can be loaded or not. */ - public static boolean isRunningInTest() { - try { - Class.forName("com.android.tv.testing.Utils"); - return true; - } catch (ClassNotFoundException e) { - return false; + public static synchronized boolean isRunningInTest() { + if (sRunningInTest == null) { + try { + Class.forName("com.android.tv.testing.Utils"); + sRunningInTest = true; + } catch (ClassNotFoundException e) { + sRunningInTest = false; + } } + return sRunningInTest; } } |