Remove termination of replica island as it does not work consistently,
and delayed termination can fail the next test.
bug 5906938

Change-Id: I5eba8965fdf3fecb6c7ce26f645da1436b0abe64
diff --git a/tests/tests/openglperf/src/android/openglperf/cts/GlAppSwitchTest.java b/tests/tests/openglperf/src/android/openglperf/cts/GlAppSwitchTest.java
index 2d7df8a..aa4ca49 100644
--- a/tests/tests/openglperf/src/android/openglperf/cts/GlAppSwitchTest.java
+++ b/tests/tests/openglperf/src/android/openglperf/cts/GlAppSwitchTest.java
@@ -80,8 +80,6 @@
         mTaskIdSelf = activity.getTaskId();
         // wait further to render some frames
         Thread.sleep(1000);
-        // terminate if it is already running
-        terminateReplicaIsland();
 
         Intent intentIsland = new Intent(Intent.ACTION_MAIN);
         intentIsland.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@@ -98,7 +96,6 @@
     @Override
     protected void tearDown() throws Exception {
         showOrHideReplicaIsland(false);
-        terminateReplicaIsland();
         super.tearDown();
     }
 
@@ -140,7 +137,8 @@
         List<ActivityManager.RunningTaskInfo> tasks =
                 mActivityManager.getRunningTasks(MAX_RUNNING_TASKS);
         for (ActivityManager.RunningTaskInfo info : tasks) {
-            if (info.id == mTaskIdReplica) {
+            String packageName = info.baseActivity.getPackageName();
+            if (packageName.contentEquals(REPLICA_ISLAND_PACKAGE)) {
                 foundReplica = true;
                 break;
             }
@@ -156,12 +154,4 @@
     private void showOrHideReplicaIsland(boolean show) {
         mActivityManager.moveTaskToFront(show ? mTaskIdReplica : mTaskIdSelf, 0);
     }
-
-    /**
-     * this API works only when the replica island is in background.
-     */
-    private void terminateReplicaIsland() {
-        mActivityManager.killBackgroundProcesses(REPLICA_ISLAND_PACKAGE);
-        getInstrumentation().waitForIdleSync();
-    }
 }