Fix testTuneStress notification issue.

1)
The test expect receiving notifyVideoUnavaliable from TvInputService
at the beginning of tuning and receiving notifyVideoAvaliable or
notifyVideoUnavaliable(UNKNOW) at the end of tuning.
However, if the map value is not reset, tuning the same source for
the 2nd time, the previous value, e.g. VIDEO_AVAILABLE, will still
be kept in the map and cause wrong test result.

2)
Remove random.nextInt and add reset to guarantee video notification
will be received correctly after each tuning.

Change-Id: Ib14cd6366491481ef58ffef9f2a52b8af3b7d1e2
diff --git a/tests/tests/tv/src/android/media/tv/cts/BundledTvInputServiceTest.java b/tests/tests/tv/src/android/media/tv/cts/BundledTvInputServiceTest.java
index 9f19e03..3db68e7 100644
--- a/tests/tests/tv/src/android/media/tv/cts/BundledTvInputServiceTest.java
+++ b/tests/tests/tv/src/android/media/tv/cts/BundledTvInputServiceTest.java
@@ -33,7 +33,6 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
-import java.util.Random;
 
 /**
  * Test {@link android.media.tv.TvView}.
@@ -134,6 +133,7 @@
             return;
         }
         for (final TvInputInfo info : mPassthroughInputList) {
+            mCallback.mVideoUnavailableReasonMap.remove(info.getId());
             runTestOnUiThread(new Runnable() {
                 @Override
                 public void run() {
@@ -163,13 +163,14 @@
         // Component) and tuning should be completed within 3 seconds, which gives 15 seconds
         // for an input. Set 5 minutes of timeout for this test case and try 20 iterations.
         final int ITERATIONS = 20;
-        Random random = new Random();
         for (int i = 0; i < mPassthroughInputList.size() * ITERATIONS; ++i) {
             final TvInputInfo info =
-                    mPassthroughInputList.get(random.nextInt(mPassthroughInputList.size()));
+                    mPassthroughInputList.get(i % mPassthroughInputList.size());
+            mCallback.mVideoUnavailableReasonMap.remove(info.getId());
             runTestOnUiThread(new Runnable() {
                 @Override
                 public void run() {
+                    mTvView.reset();
                     mTvView.tune(info.getId(),
                             TvContract.buildChannelUriForPassthroughInput(info.getId()));
                 }