GTS GtsUnofficialApisUsageTestCases Failed

GTS test GtsUnofficialApisUsageTestCases fails as follows:

junit.framework.AssertionFailedError: There are 102 violation(s)
com.google.android.gm/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.gm / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.gm / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.gm / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.dialer/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.dialer / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.dialer / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.apps.photos / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setDeduplicationIds(Ljava/util/Set;)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.apps.photos / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setType(I)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.apps.photos / Landroid/media/MediaRoute2Info;- >getDeduplicationIds()Ljava/util/Set; / BLOCKED / LINKING
com.google.android.apps.photos / Landroid/media/MediaRoute2Info;- >getType()I / BLOCKED / LINKING
com.google.android.apps.photos / Landroid/window/BackEvent;- >getProgress()F / BLOCKED / LINKING
com.google.android.apps.photos / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.apps.photos / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.apps.photos / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.apps.safetyhub/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.apps.tachyon/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.apps.tachyon / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.apps.tachyon / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.apps.tachyon / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.apps.youtube.music / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setDeduplicationIds(Ljava/util/Set;)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.apps.youtube.music / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setType(I)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.apps.youtube.music / Landroid/media/MediaRoute2Info;- >getDeduplicationIds()Ljava/util/Set; / BLOCKED / LINKING
com.google.android.apps.youtube.music / Landroid/media/MediaRoute2Info;- >getType()I / BLOCKED / LINKING
com.google.android.apps.youtube.music/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.apps.youtube.music / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.apps.youtube.music / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.apps.youtube.music / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.gms / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setDeduplicationIds(Ljava/util/Set;)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.gms / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setType(I)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.gms / Landroid/media/MediaRoute2Info;- >getDeduplicationIds()Ljava/util/Set; / BLOCKED / LINKING
com.google.android.gms/Landroid/media/MediaRoute2Info;- >getType()I/BLOCKED/LINKING
com.google.android.gms/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.gms / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.gms / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.gms / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.tts/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.tts / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.tts / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.tts / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.as/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.as / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.as / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.as / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.keep/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.keep / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.keep / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.keep / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.apps.docs/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.apps.docs/Landroid/window/BackEvent;- >getSwipeEdge()I/BLOCKED/LINKING
com.google.android.apps.docs/Landroid/window/BackEvent;- >getTouchX()F/BLOCKED/LINKING
com.google.android.apps.docs/Landroid/window/BackEvent;- >getTouchY()F/BLOCKED/LINKING
com.google.android.calendar/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.calendar / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.calendar/Landroid/window/BackEvent;- >getTouchX()F/BLOCKED/LINKING
com.google.android.calendar/Landroid/window/BackEvent;- >getTouchY()F/BLOCKED/LINKING
com.google.android.inputmethod.latin/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.inputmethod.latin / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.inputmethod.latin/Landroid/window/BackEvent;- >getTouchX()F/BLOCKED/LINKING
com.google.android.inputmethod.latin/Landroid/window/BackEvent;- >getTouchY()F/BLOCKED/LINKING
com.google.android.apps.messaging/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.apps.messaging / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.apps.messaging / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.apps.messaging / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.apps.maps / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setDeduplicationIds(Ljava/util/Set;)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.apps.maps / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setType(I)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.apps.maps / Landroid/media/MediaRoute2Info;- >getDeduplicationIds()Ljava/util/Set; / BLOCKED / LINKING
com.google.android.apps.maps / Landroid/media/MediaRoute2Info;- >getType()I / BLOCKED / LINKING
com.google.android.apps.maps / Landroid/window/BackEvent;- >getProgress()F / BLOCKED / LINKING
com.google.android.apps.maps / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.apps.maps / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.apps.maps / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.deskclock / Landroid/window/BackEvent;- >getProgress()F / BLOCKED / LINKING
com.google.android.deskclock / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.contacts/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.contacts / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.contacts/Landroid/window/BackEvent;- >getTouchX()F/BLOCKED/LINKING
com.google.android.contacts / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.googlequicksearchbox / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setDeduplicationIds(Ljava/util/Set;)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.googlequicksearchbox / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setType(I)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.googlequicksearchbox / Landroid/media/MediaRoute2Info;- >getDeduplicationIds()Ljava/util/Set; / BLOCKED / LINKING
com.google.android.googlequicksearchbox/Landroid/media/MediaRoute2Info;- >getType()I/BLOCKED/LINKING
com.google.android.googlequicksearchbox/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.googlequicksearchbox / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.googlequicksearchbox / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.googlequicksearchbox / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.youtube / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setDeduplicationIds(Ljava/util/Set;)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.youtube / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setType(I)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.youtube / Landroid/media/MediaRoute2Info;- >getDeduplicationIds()Ljava/util/Set; / BLOCKED / LINKING
com.google.android.youtube/Landroid/media/MediaRoute2Info;- >getType()I/BLOCKED/LINKING
com.google.android.youtube/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.youtube / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.youtube/Landroid/window/BackEvent;- >getTouchX()F/BLOCKED/LINKING
com.google.android.youtube / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
com.google.android.videos / Landroid/media/MediaRoute2Info$Builder; - >setDeduplicationIds(Ljava/util/Set;)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.videos / Landroid/media/MediaRoute2Info$Builder;- & amp;gt;setType(I)Landroid/media/MediaRoute2Info$Builder; / BLOCKED / LINKING
com.google.android.videos / Landroid/media/MediaRoute2Info;- >getDeduplicationIds()Ljava/util/Set; / BLOCKED / LINKING
com.google.android.videos / Landroid/media/MediaRoute2Info;- >getType()I / BLOCKED / LINKING
com.google.android.videos/Landroid/window/BackEvent;- >getProgress()F/BLOCKED/LINKING
com.google.android.videos / Landroid/window/BackEvent;- >getSwipeEdge()I / BLOCKED / LINKING
com.google.android.videos / Landroid/window/BackEvent;- >getTouchX()F / BLOCKED / LINKING
com.google.android.videos / Landroid/window/BackEvent;- >getTouchY()F / BLOCKED / LINKING
    at junit.framework.Assert.fail(Assert.java:57)
    at junit.framework.TestCase.fail(TestCase.java:223)
    at com.android.gts.api.UnofficialApisUsageTest.testNonApiReferencesInProduct(UnofficialApisUsageTest.java:211)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at junit.framework.TestCase.runTest(TestCase.java:177)
    at junit.framework.TestCase.runBare(TestCase.java:142)
    at com.android.tradefed.testtype.DeviceTestResult$1.protect(DeviceTestResult.java:99)
    at com.android.tradefed.testtype.DeviceTestResult.runProtected(DeviceTestResult.java:73)
    at com.android.tradefed.testtype.DeviceTestResult.run(DeviceTestResult.java:104)
    at junit.framework.TestCase.run(TestCase.java:130)
    at com.android.tradefed.testtype.DeviceTestCase.run(DeviceTestCase.java:170)
    at com.android.tradefed.testtype.JUnitRunUtil.runTest(JUnitRunUtil.java:65)
    at com.android.tradefed.testtype.JUnitRunUtil.runTest(JUnitRunUtil.java:44)
    at com.android.tradefed.testtype.JUnitRunUtil.runTest(JUnitRunUtil.java:39)
    at com.android.tradefed.testtype.DeviceTestCase.run(DeviceTestCase.java:146)
    at com.android.tradefed.testtype.HostTest.runRemoteTest(HostTest.java:673)
    at com.android.tradefed.testtype.HostTest.runTestClasses(HostTest.java:581)
    at com.android.tradefed.testtype.HostTest.run(HostTest.java:564)
    at com.android.compatibility.common.tradefed.testtype.JarHostTest.run(JarHostTest.java:56)
    at com.android.tradefed.testtype.suite.GranularRetriableTestWrapper.intraModuleRun(GranularRetriableTestWrapper.java:366)
    at com.android.tradefed.testtype.suite.GranularRetriableTestWrapper.run(GranularRetriableTestWrapper.java:277)
    at com.android.tradefed.testtype.suite.ModuleDefinition.run(ModuleDefinition.java:581)
    at com.android.tradefed.testtype.suite.ITestSuite.runSingleModule(ITestSuite.java:912)
    at com.android.tradefed.testtype.suite.ITestSuite.run(ITestSuite.java:792)
    at com.android.tradefed.invoker.InvocationExecution.runTest(InvocationExecution.java:1335)
    at com.android.tradefed.invoker.InvocationExecution.runTests(InvocationExecution.java:1114)
    at com.android.tradefed.invoker.TestInvocation.prepareAndRun(TestInvocation.java:604)
    at com.android.tradefed.invoker.TestInvocation.performInvocation(TestInvocation.java:274)
    at com.android.tradefed.invoker.TestInvocation.invoke(TestInvocation.java:1322)
    at com.android.tradefed.command.CommandScheduler$InvocationThread.run(CommandScheduler.java:629)

The apps with the above failure prompts are all Google’s native applications, such as com.google.android.youtube (YouTube), and these apps are located in the product directory. We can decompile and take a look at this test item:

You can see that this test item mainly tests whether the app in the product directory calls the api in the blacklist or greylist, that is, the api in the non-SDK interface control list. The list is as follows:

All applications that call non-SDK (including dark gray list, blacklist) interfaces after Android P will be affected. The tool veridex provided by Google can detect whether the app calls these APIs. It contains an appcompat.sh. We can see GTS Also use this script

1: The source code contains this tool, the directory is: QSSI.13\art\tools\veridex\appcompat.sh
2: We can compile this tool in the QSSI.13 directory: make appcompat
3: We can use the following command line to output the scanned content to a file
./appcompat.sh --dex-file=my_game.apk.apk >> out_put.txt
Of course, you can also add a --imprecise parameter. This parameter is added to make the output more detailed.
./appcompat.sh --dex-file=my_game.apk --imprecise >> out_put.txt

The screenshot shows the scanned non-SDK API. It scanned out 92 hidden APIs, 52 reflection APIs, and some others. For example, the maximum of 7 APIs only supports up to q. Of course, this does not mean that these APIs cannot be called. The filter conditions for GTS test failure are:

That is to say, only the APIs in red in the picture below will be considered non-standard. Linking unsupported or Reflection unsupported below can be considered normal.

Of course, there is another judgment: this item is to read the GTS configuration file: whether additional api is configured in GtsUnofficialApisUsageTestCases.dynamic. If not configured, this method is always false, and the GTS filter condition does not need to consider this condition.

But we found that these native applications must call these APIs, and we don’t have the source code, so we can’t modify it. That is to say, according to the judgment method of this testing tool, we have only one way to test this item, and that is to move these applications to other directories, such as system_ext/app or system/app directory. This is also possible, but the workload is relatively large. For example, YuTuBe is modified as follows:

#YouTube
LOCAL_PATH := $(my-dir)
....
#LOCAL_PRIVILEGED_MODULE := true
#phoebe add for move YuTuBe to system/app
#LOCAL_PRODUCT_MODULE := true
LOCAL_CERTIFICATE := PRESIGNED
LOCAL_DPI_VARIANTS := xxhdpi xhdpi hdpi mdpi
LOCAL_DPI_FILE_STEM := YouTube_$(my_src_arch)_%.apk
LOCAL_SRC_FILES := YouTube_$(my_src_arch)_xxhdpi.apk
...

Of course, some people on the Internet also say that updating these apps in Google Play Store has the same effect. After updating these apps, the directories of these apps become data/data/xxx, so this item can be considered skipped.

Of course the final cause of the problem is:

The GTS tool version has been updated from R4 to R1. If we test again at this time, it will pass. The main reason is that because the third judgment method returns true, this GTS will skip this item.