aboutsummaryrefslogtreecommitdiff
path: root/tests/input/src/com/android/tv
diff options
context:
space:
mode:
Diffstat (limited to 'tests/input/src/com/android/tv')
-rw-r--r--tests/input/src/com/android/tv/testinput/TestTvInputService.java15
-rw-r--r--tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java19
-rw-r--r--tests/input/src/com/android/tv/testinput/instrument/TestSetupInstrumentation.java2
3 files changed, 13 insertions, 23 deletions
diff --git a/tests/input/src/com/android/tv/testinput/TestTvInputService.java b/tests/input/src/com/android/tv/testinput/TestTvInputService.java
index 659b341f..621ceacb 100644
--- a/tests/input/src/com/android/tv/testinput/TestTvInputService.java
+++ b/tests/input/src/com/android/tv/testinput/TestTvInputService.java
@@ -326,11 +326,16 @@ public class TestTvInputService extends TvInputService {
if (currentSurface != null) {
String now = new Date(mCurrentPositionMs).toString();
String name = currentChannel == null ? "Null" : currentChannel.name;
- Canvas c = currentSurface.lockCanvas(null);
- c.drawColor(0xFF888888);
- c.drawText(name, 100f, 200f, mTextPaint);
- c.drawText(now, 100f, 400f, mTextPaint);
- currentSurface.unlockCanvasAndPost(c);
+ try {
+ Canvas c = currentSurface.lockCanvas(null);
+ c.drawColor(0xFF888888);
+ c.drawText(name, 100f, 200f, mTextPaint);
+ c.drawText(now, 100f, 400f, mTextPaint);
+ // Assuming c.drawXXX will never fail.
+ currentSurface.unlockCanvasAndPost(c);
+ } catch (IllegalArgumentException e) {
+ // The surface might have been abandoned. Ignore the exception.
+ }
if (DEBUG) {
Log.v(TAG, "Post to canvas");
}
diff --git a/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java b/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java
index 732972cc..a793ac71 100644
--- a/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java
+++ b/tests/input/src/com/android/tv/testinput/TestTvInputSetupActivity.java
@@ -20,13 +20,10 @@ import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
-import android.content.ContentResolver;
-import android.content.ContentValues;
import android.content.Context;
import android.content.DialogInterface;
import android.media.tv.TvContract;
import android.media.tv.TvInputInfo;
-import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
@@ -58,39 +55,27 @@ public class TestTvInputSetupActivity extends Activity {
private void registerChannels(int channelCount) {
TestTvInputSetupActivity context = this;
- registerChannels(context, mInputId, false, channelCount);
+ registerChannels(context, mInputId, channelCount);
}
- public static void registerChannels(Context context, String inputId, boolean updateBrowsable,
- int channelCount) {
+ public static void registerChannels(Context context, String inputId, int channelCount) {
Log.i(TAG, "Registering " + channelCount + " channels");
List<ChannelInfo> channels = new ArrayList<>();
for (int i = 1; i <= channelCount; i++) {
channels.add(ChannelInfo.create(context, i));
}
ChannelUtils.updateChannels(context, inputId, channels);
- if (updateBrowsable) {
- updateChannelsBrowsable(context.getContentResolver(), inputId);
- }
// Reload channels so we have the ids.
Map<Long, ChannelInfo> channelIdToInfoMap =
ChannelUtils.queryChannelInfoMapForTvInput(context, inputId);
for (Long channelId : channelIdToInfoMap.keySet()) {
- // TODO: http://b/21705569 Create better program info for tests
ProgramInfo programInfo = ProgramInfo.create();
ProgramUtils.populatePrograms(context, TvContract.buildChannelUri(channelId),
programInfo);
}
}
- private static void updateChannelsBrowsable(ContentResolver contentResolver, String inputId) {
- Uri uri = TvContract.buildChannelsUriForInput(inputId);
- ContentValues values = new ContentValues();
- values.put(TvContract.Channels.COLUMN_BROWSABLE, 1);
- contentResolver.update(uri, values, null, null);
- }
-
public static class MyAlertDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
diff --git a/tests/input/src/com/android/tv/testinput/instrument/TestSetupInstrumentation.java b/tests/input/src/com/android/tv/testinput/instrument/TestSetupInstrumentation.java
index 379bce86..48e485c5 100644
--- a/tests/input/src/com/android/tv/testinput/instrument/TestSetupInstrumentation.java
+++ b/tests/input/src/com/android/tv/testinput/instrument/TestSetupInstrumentation.java
@@ -104,7 +104,7 @@ public class TestSetupInstrumentation extends Instrumentation {
throw new TestSetupException(
"Unknown " + TEST_SETUP_MODE_ARG + " of " + testSetupMode);
}
- TestTvInputSetupActivity.registerChannels(getContext(), mInputId, true, channelCount);
+ TestTvInputSetupActivity.registerChannels(getContext(), mInputId, channelCount);
}
}