Merge "Use dynamicconfig url for CTS_v2 MediaPreparer" into nyc-dev
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index 285c8da..5409a76 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -238,6 +238,14 @@
             new Feature(PackageManager.FEATURE_FINGERPRINT, false),
     };
 
+    public static final Feature[] ALL_NYC_FEATURES = {
+            new Feature(PackageManager.FEATURE_VR_MODE, false),
+            new Feature(PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE, false),
+            new Feature(PackageManager.FEATURE_VULKAN_HARDWARE_VERSION, false),
+            new Feature(PackageManager.FEATURE_VULKAN_HARDWARE_LEVEL, false),
+            new Feature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION_NFCF, false),
+    };
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -269,6 +277,9 @@
 
         // add features from latest to last so that the latest requirements are put in the set first
         int apiVersion = Build.VERSION.SDK_INT;
+        if (apiVersion >= Build.VERSION_CODES.N) {
+            Collections.addAll(features, ALL_NYC_FEATURES);
+        }
         if (apiVersion >= Build.VERSION_CODES.M) {
             Collections.addAll(features, ALL_MNC_FEATURES);
         }
diff --git a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
index fd7dac7..531511c 100644
--- a/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
+++ b/hostsidetests/appsecurity/test-apps/EncryptionApp/src/com/android/cts/encryptionapp/EncryptionAppTest.java
@@ -144,7 +144,13 @@
         // Enter current PIN
         UiObject view = new UiObject(new UiSelector()
                 .resourceId("com.android.settings:id/password_entry"));
-        assertTrue("password_entry", view.waitForExists(TIMEOUT));
+        if (!view.waitForExists(TIMEOUT)) {
+            // Odd, maybe there is a crash dialog showing; try dismissing it
+            mDevice.pressBack();
+            mDevice.waitForIdle();
+
+            assertTrue("password_entry", view.waitForExists(TIMEOUT));
+        }
 
         enterTestPin();
 
diff --git a/hostsidetests/services/activitymanager/appDisplaySize/src/android/displaysize/app/SmallestWidthActivity.java b/hostsidetests/services/activitymanager/appDisplaySize/src/android/displaysize/app/SmallestWidthActivity.java
index c29c0c5..b3f8c39 100644
--- a/hostsidetests/services/activitymanager/appDisplaySize/src/android/displaysize/app/SmallestWidthActivity.java
+++ b/hostsidetests/services/activitymanager/appDisplaySize/src/android/displaysize/app/SmallestWidthActivity.java
@@ -17,14 +17,22 @@
 package android.displaysize.app;
 
 import android.app.Activity;
+import android.content.ComponentName;
+import android.content.Intent;
 import android.os.Bundle;
 
 public class SmallestWidthActivity extends Activity {
 
     @Override
-    public void onCreate(Bundle icicle) {
-        super.onCreate(icicle);
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
 
-        // Nothing to see here.
+        final Bundle extras = intent.getExtras();
+        if (extras != null && extras.getBoolean("launch_another_activity")) {
+            Intent startIntent = new Intent();
+            startIntent.setComponent(
+                    new ComponentName("android.server.app", "android.server.app.TestActivity"));
+            startActivity(startIntent);
+        }
     }
 }
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
index 0e4dded..1975aff 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerAppConfigurationTests.java
@@ -27,16 +27,41 @@
      * and heights. The values reported in fullscreen should be larger than those reported in
      * docked state.
      */
-    public void testConfigurationUpdatesWhenResized() throws Exception {
+    public void testConfigurationUpdatesWhenResizedFromFullscreen() throws Exception {
         launchActivityInStack(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID);
         final ReportedSizes fullscreenSizes = getActivityDisplaySize(TEST_ACTIVITY_NAME,
                 FULLSCREEN_WORKSPACE_STACK_ID);
-        final boolean portrait = fullscreenSizes.displayWidth < fullscreenSizes.displayHeight;
 
-        moveActivityToDockStack(TEST_ACTIVITY_NAME);
+        moveActivityToStack(TEST_ACTIVITY_NAME, DOCKED_STACK_ID);
         final ReportedSizes dockedSizes = getActivityDisplaySize(TEST_ACTIVITY_NAME,
                 DOCKED_STACK_ID);
 
+        assertSizesAreSane(fullscreenSizes, dockedSizes);
+    }
+
+    /**
+     * Same as {@link #testConfigurationUpdatesWhenResizedFromFullscreen()} but resizing
+     * from docked state to fullscreen (reverse).
+     */
+    public void testConfigurationUpdatesWhenResizedFromDockedStack() throws Exception {
+        launchActivityInStack(TEST_ACTIVITY_NAME, DOCKED_STACK_ID);
+        final ReportedSizes dockedSizes = getActivityDisplaySize(TEST_ACTIVITY_NAME,
+                DOCKED_STACK_ID);
+
+        moveActivityToStack(TEST_ACTIVITY_NAME, FULLSCREEN_WORKSPACE_STACK_ID);
+        final ReportedSizes fullscreenSizes = getActivityDisplaySize(TEST_ACTIVITY_NAME,
+                FULLSCREEN_WORKSPACE_STACK_ID);
+
+        assertSizesAreSane(fullscreenSizes, dockedSizes);
+    }
+
+    /**
+     * Throws an AssertionError if fullscreenSizes has widths/heights (depending on aspect ratio)
+     * that are smaller than the dockedSizes.
+     */
+    private static void assertSizesAreSane(ReportedSizes fullscreenSizes, ReportedSizes dockedSizes)
+            throws Exception {
+        final boolean portrait = fullscreenSizes.displayWidth < fullscreenSizes.displayHeight;
         if (portrait) {
             assertTrue(dockedSizes.displayHeight < fullscreenSizes.displayHeight);
             assertTrue(dockedSizes.heightDp < fullscreenSizes.heightDp);
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
index 8111bac..0100102 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/ActivityManagerTestBase.java
@@ -154,8 +154,12 @@
     }
 
     protected void moveActivityToDockStack(String activityName) throws Exception {
+        moveActivityToStack(activityName, DOCKED_STACK_ID);
+    }
+
+    protected void moveActivityToStack(String activityName, int stackId) throws Exception {
         final int taskId = getActivityTaskId(activityName);
-        final String cmd = AM_MOVE_TASK + taskId + " " + DOCKED_STACK_ID + " true";
+        final String cmd = AM_MOVE_TASK + taskId + " " + stackId + " true";
         executeShellCommand(cmd);
     }
 
@@ -238,16 +242,13 @@
     }
 
     private boolean isDisplayOn() throws DeviceNotAvailableException {
-        final Pattern displayStatePattern = Pattern.compile("Display Power: state=(.+)");
         final CollectingOutputReceiver outputReceiver = new CollectingOutputReceiver();
         mDevice.executeShellCommand("dumpsys power", outputReceiver);
-        final LinkedList<String> dumpLines = new LinkedList();
-        Collections.addAll(dumpLines, outputReceiver.getOutput().split("\\n"));
 
-        while (!dumpLines.isEmpty()) {
-            final String line = dumpLines.pop().trim();
+        for (String line : outputReceiver.getOutput().split("\\n")) {
+            line = line.trim();
 
-            Matcher matcher = displayStatePattern.matcher(line);
+            final Matcher matcher = sDisplayStatePattern.matcher(line);
             if (matcher.matches()) {
                 final String state = matcher.group(1);
                 log("power state=" + state);
@@ -370,6 +371,8 @@
     private static final Pattern sDestroyPattern = Pattern.compile("(.+): onDestroy");
     private static final Pattern sNewConfigPattern = Pattern.compile(
                     "(.+): config size=\\((\\d+),(\\d+)\\) displaySize=\\((\\d+),(\\d+)\\)");
+    private static final Pattern sDisplayStatePattern =
+            Pattern.compile("Display Power: state=(.+)");
 
     protected class ReportedSizes {
         int widthDp;
diff --git a/hostsidetests/services/activitymanager/src/android/server/cts/DisplaySizeTest.java b/hostsidetests/services/activitymanager/src/android/server/cts/DisplaySizeTest.java
index 9813b00..4dbb704 100644
--- a/hostsidetests/services/activitymanager/src/android/server/cts/DisplaySizeTest.java
+++ b/hostsidetests/services/activitymanager/src/android/server/cts/DisplaySizeTest.java
@@ -41,12 +41,6 @@
         super.setUp();
 
         mDevice = getDevice();
-
-        // Set device to 0.85 zoom. It doesn't matter that we're zooming out
-        // since the feature verifies that we're in a non-default density.
-        final int stableDensity = getStableDensity();
-        final int targetDensity = (int) (stableDensity * 0.85);
-        setDensity(targetDensity);
     }
 
     @Override
@@ -54,22 +48,63 @@
         super.tearDown();
 
         try {
-            // Restore default density.
-            mDevice.executeShellCommand("wm density reset");
+            resetDensity();
 
             // Ensure app process is stopped.
             forceStopPackage("android.displaysize.app");
+            forceStopPackage("android.server.app");
         } catch (DeviceNotAvailableException e) {
             // Do nothing.
         }
     }
 
     public void testCompatibilityDialog() throws Exception {
+        // Launch some other app (not to perform density change on launcher).
+        startActivity("android.server.app", "TestActivity");
+        verifyWindowDisplayed("TestActivity", ACTIVITY_TIMEOUT_MILLIS);
+
+        setUnsupportedDensity();
+
+        // Launch target app.
         startActivity("android.displaysize.app", "SmallestWidthActivity");
         verifyWindowDisplayed("SmallestWidthActivity", ACTIVITY_TIMEOUT_MILLIS);
         verifyWindowDisplayed("UnsupportedDisplaySizeDialog", WINDOW_TIMEOUT_MILLIS);
     }
 
+    public void testCompatibilityDialogWhenFocused() throws Exception {
+        startActivity("android.displaysize.app", "SmallestWidthActivity");
+        verifyWindowDisplayed("SmallestWidthActivity", ACTIVITY_TIMEOUT_MILLIS);
+
+        setUnsupportedDensity();
+
+        verifyWindowDisplayed("UnsupportedDisplaySizeDialog", WINDOW_TIMEOUT_MILLIS);
+    }
+
+    public void testCompatibilityDialogAfterReturn() throws Exception {
+        // Launch target app.
+        startActivity("android.displaysize.app", "SmallestWidthActivity");
+        verifyWindowDisplayed("SmallestWidthActivity", ACTIVITY_TIMEOUT_MILLIS);
+        // Launch another activity.
+        startOtherActivityOnTop("android.displaysize.app", "SmallestWidthActivity");
+        verifyWindowDisplayed("TestActivity", ACTIVITY_TIMEOUT_MILLIS);
+
+        setUnsupportedDensity();
+
+        // Go back.
+        mDevice.executeShellCommand("input keyevent 4");
+
+        verifyWindowDisplayed("SmallestWidthActivity", ACTIVITY_TIMEOUT_MILLIS);
+        verifyWindowDisplayed("UnsupportedDisplaySizeDialog", WINDOW_TIMEOUT_MILLIS);
+    }
+
+    private void setUnsupportedDensity() throws DeviceNotAvailableException {
+        // Set device to 0.85 zoom. It doesn't matter that we're zooming out
+        // since the feature verifies that we're in a non-default density.
+        final int stableDensity = getStableDensity();
+        final int targetDensity = (int) (stableDensity * 0.85);
+        setDensity(targetDensity);
+    }
+
     private int getStableDensity() {
         try {
             final String densityProp;
@@ -95,6 +130,10 @@
         assertTrue("Failed to set density to " + targetDensity, success);
     }
 
+    private void resetDensity() throws DeviceNotAvailableException {
+        mDevice.executeShellCommand("wm density reset");
+    }
+
     private void forceStopPackage(String packageName) throws DeviceNotAvailableException {
         final String forceStopCmd = String.format(AM_FORCE_STOP, packageName);
         mDevice.executeShellCommand(forceStopCmd);
@@ -102,11 +141,20 @@
 
     private void startActivity(String packageName, String activityName)
             throws DeviceNotAvailableException {
-        final String startCmd = String.format(
-                AM_START_COMMAND, packageName, packageName, activityName);
+        mDevice.executeShellCommand(getStartCommand(packageName, activityName));
+    }
+
+    private void startOtherActivityOnTop(String packageName, String activityName)
+            throws DeviceNotAvailableException {
+        final String startCmd = getStartCommand(packageName, activityName)
+                + " -f 0x20000000 --ez launch_another_activity true";
         mDevice.executeShellCommand(startCmd);
     }
 
+    private String getStartCommand(String packageName, String activityName) {
+        return String.format(AM_START_COMMAND, packageName, packageName, activityName);
+    }
+
     private void verifyWindowDisplayed(String windowName, long timeoutMillis)
             throws DeviceNotAvailableException {
         boolean success = false;
diff --git a/hostsidetests/ui/control/src/android/taskswitching/control/cts/TaskSwitchingDeviceTest.java b/hostsidetests/ui/control/src/android/taskswitching/control/cts/TaskSwitchingDeviceTest.java
index 13b60be..dc738d6 100644
--- a/hostsidetests/ui/control/src/android/taskswitching/control/cts/TaskSwitchingDeviceTest.java
+++ b/hostsidetests/ui/control/src/android/taskswitching/control/cts/TaskSwitchingDeviceTest.java
@@ -40,6 +40,7 @@
  * Completion of launch is notified via broadcast.
  */
 public class TaskSwitchingDeviceTest extends CtsAndroidTestCase {
+    private static final String REPORT_LOG_NAME = "CtsUiHostTestCases";
     private static final String PKG_A = "android.taskswitching.appa";
     private static final String PKG_B = "android.taskswitching.appb";
     private static final String ACTIVITY_A = "AppAActivity";
@@ -84,11 +85,12 @@
                 }
             }
         });
-        DeviceReportLog report = new DeviceReportLog();
-        report.addValues("task switching time", results, ResultType.LOWER_BETTER, ResultUnit.MS);
+        String streamName = "test_measure_task_switching";
+        DeviceReportLog report = new DeviceReportLog(REPORT_LOG_NAME, streamName);
+        report.addValues("task_switching_time", results, ResultType.LOWER_BETTER, ResultUnit.MS);
         Stat.StatResult stat = Stat.getStat(results);
-        report.setSummary("task switching time", stat.mAverage,
-                ResultType.LOWER_BETTER, ResultUnit.MS);
+        report.setSummary("task_switching_time_average", stat.mAverage, ResultType.LOWER_BETTER,
+                ResultUnit.MS);
         report.submit(getInstrumentation());
     }
 
diff --git a/tests/tests/media/src/android/media/cts/AudioTrackSurroundTest.java b/tests/tests/media/src/android/media/cts/AudioTrackSurroundTest.java
index 70d74a0..aa9ac1c 100644
--- a/tests/tests/media/src/android/media/cts/AudioTrackSurroundTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioTrackSurroundTest.java
@@ -91,39 +91,55 @@
     }
 
     private void scanDevicesForEncodings() throws Exception {
+        final String MTAG = "scanDevicesForEncodings";
         // Scan devices to see which encodings are supported.
         AudioManager audioManager = (AudioManager) getContext()
                 .getSystemService(Context.AUDIO_SERVICE);
         AudioDeviceInfo[] infos = audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS);
         for (AudioDeviceInfo info : infos) {
-            log("scanDevicesForEncodings", "scanning devices, info = " + info
-                    + ", id = " + info.getId() + "---------------");
+            log(MTAG, "scanning devices, name = " + info.getProductName()
+                    + ", id = " + info.getId()
+                    + ", " + (info.isSink() ? "sink" : "source")
+                    + ", type = " + info.getType()
+                    + " ------");
+            String text = "{";
+            for (int encoding : info.getEncodings()) {
+                text += String.format("0x%08X, ", encoding);
+            }
+            text += "}";
+            log(MTAG, "  encodings = " + text);
+            text = "{";
+            for (int rate : info.getSampleRates()) {
+                text += rate + ", ";
+            }
+            text += "}";
+            log(MTAG, "  sample rates = " + text);
             if (info.isSink()) {
                 for (int encoding : info.getEncodings()) {
                     switch (encoding) {
                         case AudioFormat.ENCODING_PCM_16BIT:
                             mInfoPCM16 = info;
-                            log(TAG, "mInfoPCM16 set to " + info);
+                            log(MTAG, "mInfoPCM16 set to " + info);
                             break;
                         case AudioFormat.ENCODING_AC3:
                             mInfoAC3 = info;
-                            log(TAG, "mInfoAC3 set to " + info);
+                            log(MTAG, "mInfoAC3 set to " + info);
                             break;
                         case AudioFormat.ENCODING_E_AC3:
                             mInfoE_AC3 = info;
-                            log(TAG, "mInfoE_AC3 set to " + info);
+                            log(MTAG, "mInfoE_AC3 set to " + info);
                             break;
                         case AudioFormat.ENCODING_DTS:
                             mInfoDTS = info;
-                            log(TAG, "mInfoDTS set to " + info);
+                            log(MTAG, "mInfoDTS set to " + info);
                             break;
                         case AudioFormat.ENCODING_DTS_HD:
                             mInfoDTS_HD = info;
-                            log(TAG, "mInfoDTS_HD set to " + info);
+                            log(MTAG, "mInfoDTS_HD set to " + info);
                             break;
                         case AudioFormat.ENCODING_IEC61937:
                             mInfoIEC61937 = info;
-                            log(TAG, "mInfoIEC61937 set to " + info);
+                            log(MTAG, "mInfoIEC61937 set to " + info);
                             break;
                         default:
                             // This is OK. It is just an encoding that we don't care about.
@@ -337,6 +353,9 @@
 
                 // Play for a while.
                 mTrack.play();
+
+                log(TEST_NAME, "native rate = "
+                        + mTrack.getNativeOutputSampleRate(mTrack.getStreamType()));
                 long elapsedMillis = 0;
                 long startTime = System.currentTimeMillis();
                 while (elapsedMillis < TEST_DURATION_MILLIS) {
diff --git a/tests/tests/net/appForApi23/AndroidManifest.xml b/tests/tests/net/appForApi23/AndroidManifest.xml
index 7203ea5..ed4cedb 100644
--- a/tests/tests/net/appForApi23/AndroidManifest.xml
+++ b/tests/tests/net/appForApi23/AndroidManifest.xml
@@ -28,7 +28,7 @@
                 <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
             </intent-filter>
             <intent-filter>
-                <action android:name="android.net.cts.appForApi23.getConnectivityActionCount" />
+                <action android:name="android.net.cts.appForApi23.getWifiConnectivityActionCount" />
             </intent-filter>
         </receiver>
 
diff --git a/tests/tests/net/appForApi23/src/android/net/cts/appForApi23/ConnectivityReceiver.java b/tests/tests/net/appForApi23/src/android/net/cts/appForApi23/ConnectivityReceiver.java
index 5dd77e8..8039a4f 100644
--- a/tests/tests/net/appForApi23/src/android/net/cts/appForApi23/ConnectivityReceiver.java
+++ b/tests/tests/net/appForApi23/src/android/net/cts/appForApi23/ConnectivityReceiver.java
@@ -21,18 +21,21 @@
 import android.net.ConnectivityManager;
 
 public class ConnectivityReceiver extends BroadcastReceiver {
-    public static String GET_CONNECTIVITY_ACTION_COUNT =
-            "android.net.cts.appForApi23.getConnectivityActionCount";
+    public static String GET_WIFI_CONNECTIVITY_ACTION_COUNT =
+            "android.net.cts.appForApi23.getWifiConnectivityActionCount";
 
-    private static int sConnectivityActionCount = 0;
+    private static int sWifiConnectivityActionCount = 0;
 
     @Override
     public void onReceive(Context context, Intent intent) {
         if (ConnectivityManager.CONNECTIVITY_ACTION.equals(intent.getAction())) {
-            sConnectivityActionCount++;
+            int networkType = intent.getIntExtra(ConnectivityManager.EXTRA_NETWORK_TYPE, 0);
+            if (networkType == ConnectivityManager.TYPE_WIFI) {
+                sWifiConnectivityActionCount++;
+            }
         }
-        if (GET_CONNECTIVITY_ACTION_COUNT.equals(intent.getAction())) {
-            setResultCode(sConnectivityActionCount);
+        if (GET_WIFI_CONNECTIVITY_ACTION_COUNT.equals(intent.getAction())) {
+            setResultCode(sWifiConnectivityActionCount);
         }
     }
 }
diff --git a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
index df2baac..b8478d2 100644
--- a/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
+++ b/tests/tests/net/src/android/net/cts/ConnectivityManagerTest.java
@@ -77,9 +77,9 @@
     private static final String NETWORK_CALLBACK_ACTION =
             "ConnectivityManagerTest.NetworkCallbackAction";
 
-    // Intent string to get the number of CONNECTIVITY_ACTION callbacks the test app has seen
-    public static final String GET_CONNECTIVITY_ACTION_COUNT =
-            "android.net.cts.appForApi23.getConnectivityActionCount";
+    // Intent string to get the number of wifi CONNECTIVITY_ACTION callbacks the test app has seen
+    public static final String GET_WIFI_CONNECTIVITY_ACTION_COUNT =
+            "android.net.cts.appForApi23.getWifiConnectivityActionCount";
 
     // device could have only one interface: data, wifi.
     private static final int MIN_NUM_NETWORK_TYPES = 1;
@@ -423,7 +423,7 @@
 
         toggleWifi();
 
-        Intent getConnectivityCount = new Intent(GET_CONNECTIVITY_ACTION_COUNT);
+        Intent getConnectivityCount = new Intent(GET_WIFI_CONNECTIVITY_ACTION_COUNT);
         assertEquals(2, sendOrderedBroadcastAndReturnResultCode(
                 getConnectivityCount, SEND_BROADCAST_TIMEOUT));
     }
diff --git a/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
index 51004d6..e8de02d 100644
--- a/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
+++ b/tests/tests/permission2/src/android/permission2/cts/PermissionPolicyTest.java
@@ -115,7 +115,8 @@
             if (!expectedPermissionGroups.contains(declaredGroup.name)) {
                 assertFalse("Cannot define group " + declaredGroup.name + " in android namespace",
                         declaredGroup.name != null
-                        && declaredGroup.name.startsWith(PLATFORM_ROOT_NAMESPACE));
+                                && declaredGroup.packageName.equals(PLATFORM_PACKAGE_NAME)
+                                && declaredGroup.name.startsWith(PLATFORM_ROOT_NAMESPACE));
             }
         }
     }
diff --git a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SurfaceViewTests.java b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SurfaceViewTests.java
index 1f49615..901792d 100644
--- a/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SurfaceViewTests.java
+++ b/tests/tests/uirendering/src/android/uirendering/cts/testclasses/SurfaceViewTests.java
@@ -104,52 +104,4 @@
                 .addLayout(R.layout.frame_layout, initializer, true)
                 .runWithAnimationVerifier(new ColorVerifier(Color.WHITE, 0 /* zero tolerance */));
     }
-
-    /*
-     * This test draws 5 frames with a green surfaceview, then 5 frames where the surfaceview
-     * is skipped during the draw. This should result in just the white of the activity
-     * being visible, as the surfaceview is being rejected during the draw pass regardless
-     * of its current position/visibility in the view tree.
-     */
-    @Test
-    public void testStopDrawingSurfaceView() {
-
-        final CountDownLatch fence = new CountDownLatch(1);
-        ViewInitializer initializer = new ViewInitializer() {
-            @Override
-            public void initializeView(View view) {
-                FrameLayout root = (FrameLayout) view.findViewById(R.id.frame_layout);
-
-                FrameLayout container = new FrameLayout(view.getContext()) {
-                    int mDrawsRemaining = DrawActivity.MIN_NUMBER_OF_DRAWS + 10;
-                    @Override
-                    protected void dispatchDraw(Canvas canvas) {
-                        if (mDrawsRemaining > 5) {
-                            super.dispatchDraw(canvas);
-                        }
-                        if (--mDrawsRemaining > 0) {
-                            invalidate();
-                        } else {
-                            fence.countDown();
-                        }
-                    }
-                };
-                SurfaceView surfaceViewA = new SurfaceView(view.getContext());
-                surfaceViewA.getHolder().addCallback(sGreenCanvasCallback);
-                // Must be ZOrderOnTop(true) otherwise when we stop drawing
-                // the surfaceview the lack of a hole punch will make it visually
-                // appear to work even if it is still incorrectly part of SF's list
-                // of compositing layers.
-                surfaceViewA.setZOrderOnTop(true);
-                container.addView(surfaceViewA, new FrameLayout.LayoutParams(
-                        90, 40, Gravity.START | Gravity.TOP));
-                root.addView(container, new FrameLayout.LayoutParams(
-                        FrameLayout.LayoutParams.MATCH_PARENT,
-                        FrameLayout.LayoutParams.MATCH_PARENT));
-            }
-        };
-        createTest()
-                .addLayout(R.layout.frame_layout, initializer, true, fence)
-                .runWithAnimationVerifier(new ColorVerifier(Color.WHITE, 0 /* zero tolerance */));
-    }
 }