aboutsummaryrefslogtreecommitdiff
path: root/tests/common/src/com/android/tv/testing/Utils.java
diff options
context:
space:
mode:
authorNick Chalko <nchalko@google.com>2017-10-03 10:16:37 -0700
committerNick Chalko <nchalko@google.com>2017-10-04 13:48:13 +0000
commit6ebde20b03db4c0d57f67acaac11832b610b966b (patch)
treed31e2adc1f9cce4f27ca07d30bee921032e33a3c /tests/common/src/com/android/tv/testing/Utils.java
parentee027a576ddebaf1ae739219be01b0240b15f80c (diff)
downloadTV-6ebde20b03db4c0d57f67acaac11832b610b966b.tar.gz
Sync to match Live Channels 1.15(ncis)oreo-mr1-dev
aka ub-tv-dev at a73a150bb7d0d1ce867ef980c6ac8411899d40ad Bug: 64021596 Change-Id: I7c544fd15e2c58784f8babc31877ad0dfeebb4c0 (cherry picked from commit 633eb826b8c97731dfc5ef12c7bf78a63734275d)
Diffstat (limited to 'tests/common/src/com/android/tv/testing/Utils.java')
-rw-r--r--tests/common/src/com/android/tv/testing/Utils.java38
1 files changed, 13 insertions, 25 deletions
diff --git a/tests/common/src/com/android/tv/testing/Utils.java b/tests/common/src/com/android/tv/testing/Utils.java
index 66a13466..b2b4036e 100644
--- a/tests/common/src/com/android/tv/testing/Utils.java
+++ b/tests/common/src/com/android/tv/testing/Utils.java
@@ -19,16 +19,15 @@ package com.android.tv.testing;
import android.content.ComponentName;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.pm.PackageManager;
import android.content.pm.ServiceInfo;
import android.content.res.Resources;
import android.media.tv.TvInputInfo;
import android.media.tv.TvInputManager;
import android.net.Uri;
-import android.os.Looper;
import android.util.Log;
import com.android.tv.common.TvCommonUtils;
-import com.android.tv.util.MainThreadExecutor;
import java.io.IOException;
import java.io.InputStream;
@@ -37,8 +36,6 @@ import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Random;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
/**
* An utility class for testing.
@@ -101,27 +98,6 @@ public final class Utils {
return new Random(DEFAULT_RANDOM_SEED);
}
- /**
- * Executes a call on the main thread, blocking until it is completed.
- *
- * <p>Useful for doing things that are not thread-safe, such as looking at or modifying the view
- * hierarchy.
- *
- * @param runnable The code to run on the main thread.
- */
- public static void runOnMainSync(Runnable runnable) {
- if (Looper.myLooper() == Looper.getMainLooper()) {
- runnable.run();
- } else {
- Future<?> temp = MainThreadExecutor.getInstance().submit(runnable);
- try {
- temp.get();
- } catch (InterruptedException | ExecutionException e) {
- throw new RuntimeException(e);
- }
- }
- }
-
private static long getSeed() {
// Set random seed as the date to track failed test data easily.
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd", Locale.getDefault());
@@ -131,4 +107,16 @@ public final class Utils {
}
private Utils() {}
+
+ /**
+ * Checks whether TvActivity is enabled or not.
+ */
+ public static boolean isTvActivityEnabled(Context context) {
+ PackageManager pm = context.getPackageManager();
+ ComponentName name = new ComponentName("com.android.tv",
+ "com.android.tv.TvActivity");
+ int enabled = pm.getComponentEnabledSetting(name);
+ return enabled == PackageManager.COMPONENT_ENABLED_STATE_ENABLED
+ || enabled == PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
+ }
}