check for <application android:testOnly="true">

This adds a check for "testOnly" to the existing "debuggable" check, since
they are very similar.  We should really be refactoring all the checks into
a more reasonable setup.  Since "debuggable" and "testOnly" are both set in
the same place (`<application>` in _AndroidManifest.xml_) and are both set
by the same process (running debug builds), I thought it would be OK to
include both in the same place.  Plus it was a one-line change.
This commit is contained in:
Hans-Christoph Steiner 2024-04-01 12:40:14 +02:00 committed by Michael Pöhn
parent 0cf1749ec3
commit 9c65bed4a5
6 changed files with 26 additions and 16 deletions

View file

@ -2677,10 +2677,13 @@ def ensure_final_value(packageName, arsc, value):
return ''
def is_apk_and_debuggable(apkfile):
"""Return True if the given file is an APK and is debuggable.
def is_debuggable_or_testOnly(apkfile):
"""Return True if the given file is an APK and is debuggable or testOnly.
Parse only <application android:debuggable=""> from the APK.
These two settings should never be enabled in release builds. This
parses <application android:debuggable="" android:testOnly="">
from the APK and nothing else to run fast, since it is run on
every APK as part of update.
Parameters
----------
@ -2699,7 +2702,7 @@ def is_apk_and_debuggable(apkfile):
if _type == START_TAG and axml.getName() == 'application':
for i in range(0, axml.getAttributeCount()):
name = axml.getAttributeName(i)
if name == 'debuggable':
if name in ('debuggable', 'testOnly'):
_type = axml.getAttributeValueType(i)
_data = axml.getAttributeValueData(i)
value = format_value(_type, _data, lambda _: axml.getAttributeValue(i))