Merge "Build: Amend minidebug odex setup"
diff --git a/target/product/emulator.mk b/target/product/emulator.mk
index 0f33f38..3f7aa06 100644
--- a/target/product/emulator.mk
+++ b/target/product/emulator.mk
@@ -116,10 +116,9 @@
PRODUCT_COPY_FILES += \
device/generic/goldfish/init.ranchu-core.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-core.sh \
device/generic/goldfish/init.ranchu-net.sh:$(TARGET_COPY_OUT_VENDOR)/bin/init.ranchu-net.sh \
- device/generic/goldfish/init.ranchu.rc:root/init.ranchu.rc \
- device/generic/goldfish/fstab.ranchu:root/fstab.ranchu \
- device/generic/goldfish/fstab.ranchu.early:root/fstab.ranchu.early \
- device/generic/goldfish/ueventd.ranchu.rc:root/ueventd.ranchu.rc \
+ device/generic/goldfish/init.ranchu.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.ranchu.rc \
+ device/generic/goldfish/fstab.ranchu:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.ranchu \
+ device/generic/goldfish/ueventd.ranchu.rc:$(TARGET_COPY_OUT_VENDOR)/ueventd.rc \
device/generic/goldfish/input/goldfish_rotary.idc:$(TARGET_COPY_OUT_VENDOR)/usr/idc/goldfish_rotary.idc \
device/generic/goldfish/manifest.xml:$(TARGET_COPY_OUT_VENDOR)/manifest.xml \
device/generic/goldfish/data/etc/permissions/privapp-permissions-goldfish.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/privapp-permissions-goldfish.xml \
diff --git a/tools/releasetools/common.py b/tools/releasetools/common.py
index 9f9576b..b5f69a5 100644
--- a/tools/releasetools/common.py
+++ b/tools/releasetools/common.py
@@ -720,18 +720,31 @@
def GetMinSdkVersion(apk_name):
- """Get the minSdkVersion delared in the APK. This can be both a decimal number
- (API Level) or a codename.
+ """Gets the minSdkVersion declared in the APK.
+
+ It calls 'aapt' to query the embedded minSdkVersion from the given APK file.
+ This can be both a decimal number (API Level) or a codename.
+
+ Args:
+ apk_name: The APK filename.
+
+ Returns:
+ The parsed SDK version string.
+
+ Raises:
+ ExternalError: On failing to obtain the min SDK version.
"""
+ proc = Run(
+ ["aapt", "dump", "badging", apk_name], stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE)
+ stdoutdata, stderrdata = proc.communicate()
+ if proc.returncode != 0:
+ raise ExternalError(
+ "Failed to obtain minSdkVersion: aapt return code {}:\n{}\n{}".format(
+ proc.returncode, stdoutdata, stderrdata))
- p = Run(["aapt", "dump", "badging", apk_name], stdout=subprocess.PIPE)
- output, err = p.communicate()
- if err:
- raise ExternalError("Failed to obtain minSdkVersion: aapt return code %s"
- % (p.returncode,))
-
- for line in output.split("\n"):
- # Looking for lines such as sdkVersion:'23' or sdkVersion:'M'
+ for line in stdoutdata.split("\n"):
+ # Looking for lines such as sdkVersion:'23' or sdkVersion:'M'.
m = re.match(r'sdkVersion:\'([^\']*)\'', line)
if m:
return m.group(1)
@@ -739,11 +752,20 @@
def GetMinSdkVersionInt(apk_name, codename_to_api_level_map):
- """Get the minSdkVersion declared in the APK as a number (API Level). If
- minSdkVersion is set to a codename, it is translated to a number using the
- provided map.
- """
+ """Returns the minSdkVersion declared in the APK as a number (API Level).
+ If minSdkVersion is set to a codename, it is translated to a number using the
+ provided map.
+
+ Args:
+ apk_name: The APK filename.
+
+ Returns:
+ The parsed SDK version number.
+
+ Raises:
+ ExternalError: On failing to get the min SDK version number.
+ """
version = GetMinSdkVersion(apk_name)
try:
return int(version)
@@ -752,8 +774,9 @@
if version in codename_to_api_level_map:
return codename_to_api_level_map[version]
else:
- raise ExternalError("Unknown minSdkVersion: '%s'. Known codenames: %s"
- % (version, codename_to_api_level_map))
+ raise ExternalError(
+ "Unknown minSdkVersion: '{}'. Known codenames: {}".format(
+ version, codename_to_api_level_map))
def SignFile(input_name, output_name, key, password, min_api_level=None,
diff --git a/tools/releasetools/test_common.py b/tools/releasetools/test_common.py
index fb26b66..f211b03 100644
--- a/tools/releasetools/test_common.py
+++ b/tools/releasetools/test_common.py
@@ -504,6 +504,23 @@
actual = common.ParseCertificate(cert_fp.read())
self.assertEqual(expected, actual)
+ def test_GetMinSdkVersion(self):
+ test_app = os.path.join(self.testdata_dir, 'TestApp.apk')
+ self.assertEqual('24', common.GetMinSdkVersion(test_app))
+
+ def test_GetMinSdkVersion_invalidInput(self):
+ self.assertRaises(
+ common.ExternalError, common.GetMinSdkVersion, 'does-not-exist.apk')
+
+ def test_GetMinSdkVersionInt(self):
+ test_app = os.path.join(self.testdata_dir, 'TestApp.apk')
+ self.assertEqual(24, common.GetMinSdkVersionInt(test_app, {}))
+
+ def test_GetMinSdkVersionInt_invalidInput(self):
+ self.assertRaises(
+ common.ExternalError, common.GetMinSdkVersionInt, 'does-not-exist.apk',
+ {})
+
class CommonUtilsTest(unittest.TestCase):
diff --git a/tools/releasetools/testdata/TestApp.apk b/tools/releasetools/testdata/TestApp.apk
new file mode 100644
index 0000000..a911603
--- /dev/null
+++ b/tools/releasetools/testdata/TestApp.apk
Binary files differ