Add test to verify the fix for `getDexoptNeeded`.

Bug: 236682949
Bug: 236816601
Test: atest AdbRootDependentCompilationTest#testCompile_usedByOtherApps
Change-Id: I0cdbc0df462ebe49c43b879e0aa00aac3918f64a
diff --git a/hostsidetests/compilation/src/android/compilation/cts/AdbRootDependentCompilationTest.java b/hostsidetests/compilation/src/android/compilation/cts/AdbRootDependentCompilationTest.java
index 1bb14bd..c2e95a3 100644
--- a/hostsidetests/compilation/src/android/compilation/cts/AdbRootDependentCompilationTest.java
+++ b/hostsidetests/compilation/src/android/compilation/cts/AdbRootDependentCompilationTest.java
@@ -266,6 +266,11 @@
                 "android.compilation.cts.appusedbyotherapp.MyActivity.method1()",
                 "android.compilation.cts.appusedbyotherapp.MyActivity.method2()");
 
+        executeCompile(APP_USED_BY_OTHER_APP_PACKAGE, "-m", "verify");
+        // The app should not be re-compiled with a worse compiler filter even if the odex file can
+        // be public after then.
+        assertThat(getCompilerFilter(odexFilePath)).isEqualTo("speed-profile");
+
         DeviceTestRunOptions options = new DeviceTestRunOptions(APP_USING_OTHER_APP_PACKAGE);
         options.setTestClassName(APP_USING_OTHER_APP_PACKAGE + ".UsingOtherAppTest");
         options.setTestMethodName("useOtherApp");