aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools
diff options
context:
space:
mode:
authorGravatar Alex Humesky <ahumesky@google.com>2015-09-22 00:41:11 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2015-09-22 17:06:41 +0000
commitf0a5ac60547751b34b3c307a6a4e47f8c791a720 (patch)
tree8b7d781b1f948ce0df8280b0a91c8cb5e8b1fba1 /tools
parent8e055ba53848bc78a95e54c0d91c021bcc82b9c4 (diff)
Improve error message for INSTALL_FAILED_OLDER_SDK from adb.
Clean up some tests. -- MOS_MIGRATED_REVID=103600539
Diffstat (limited to 'tools')
-rw-r--r--tools/android/incremental_install.py15
-rw-r--r--tools/android/incremental_install_test.py35
2 files changed, 38 insertions, 12 deletions
diff --git a/tools/android/incremental_install.py b/tools/android/incremental_install.py
index 04da8cd0bf..c49f2ec0c2 100644
--- a/tools/android/incremental_install.py
+++ b/tools/android/incremental_install.py
@@ -106,6 +106,10 @@ class TimestampException(Exception):
"""Raised when there is a problem with timestamp reading/writing."""
+class OldSdkException(Exception):
+ """Raised when the SDK on the target device is older than the app allows."""
+
+
class Adb(object):
"""A class to handle interaction with adb."""
@@ -156,6 +160,8 @@ class Adb(object):
# "error: " to the beginning, so take it off so that we don't end up
# printing "Error: error: ..."
raise MultipleDevicesError(re.sub("^error: ", "", stderr))
+ elif "INSTALL_FAILED_OLDER_SDK" in stdout:
+ raise OldSdkException()
if adb.returncode != 0:
raise AdbError(args, adb.returncode, stdout, stderr)
@@ -729,9 +735,12 @@ def IncrementalInstall(adb_path, execroot, stub_datafile, output_marker,
sys.exit("Error: Device unauthorized. Please check the confirmation "
"dialog on your device.")
except MultipleDevicesError as e:
- sys.exit(
- "Error: " + e.message + "\nTry specifying a device serial with " +
- "\"blaze mobile-install --adb_arg=-s --adb_arg=$ANDROID_SERIAL\"")
+ sys.exit("Error: " + e.message + "\nTry specifying a device serial with "
+ "\"blaze mobile-install --adb_arg=-s --adb_arg=$ANDROID_SERIAL\"")
+ except OldSdkException as e:
+ sys.exit("Error: The device does not support the API level specified in "
+ "the application's manifest. Check minSdkVersion in "
+ "AndroidManifest.xml")
except TimestampException as e:
sys.exit("Error:\n%s" % e.message)
except AdbError as e:
diff --git a/tools/android/incremental_install_test.py b/tools/android/incremental_install_test.py
index e16a00b92c..773b348e68 100644
--- a/tools/android/incremental_install_test.py
+++ b/tools/android/incremental_install_test.py
@@ -489,8 +489,9 @@ class IncrementalInstallTest(unittest.TestCase):
try:
self._CallIncrementalInstall(incremental=True)
self.fail("Should have quit if there is no device")
- except SystemExit:
- pass
+ except SystemExit as e:
+ # make sure it's the right SystemExit reason
+ self.assertTrue("Device not found" in str(e))
def testUnauthorizedDevice(self):
self._mock_adb.SetError(1, "", "device unauthorized. Please check the "
@@ -498,8 +499,9 @@ class IncrementalInstallTest(unittest.TestCase):
try:
self._CallIncrementalInstall(incremental=True)
self.fail("Should have quit if the device is unauthorized.")
- except SystemExit:
- pass
+ except SystemExit as e:
+ # make sure it's the right SystemExit reason
+ self.assertTrue("Device unauthorized." in str(e))
def testInstallFailure(self):
self._mock_adb.SetError(0, "Failure", "", for_arg="install")
@@ -508,8 +510,9 @@ class IncrementalInstallTest(unittest.TestCase):
try:
self._CallIncrementalInstall(incremental=False)
self.fail("Should have quit if the install failed.")
- except SystemExit:
- pass
+ except SystemExit as e:
+ # make sure it's the right SystemExit reason
+ self.assertTrue("Failure" in str(e))
def testStartCold(self):
# Based on testUploadToPristineDevice
@@ -579,12 +582,13 @@ class IncrementalInstallTest(unittest.TestCase):
"more than one emulator",
]
for error in errors:
- self._mock_adb.SetError(255, "", error)
+ self._mock_adb.SetError(1, "", error)
try:
self._CallIncrementalInstall(incremental=True)
self.fail("Should have quit if there were multiple devices.")
- except SystemExit:
- pass
+ except SystemExit as e:
+ # make sure it's the right SystemExit reason
+ self.assertTrue("Try specifying a device serial" in str(e))
def testIncrementalInstallOnPristineDevice(self):
self._CreateZip()
@@ -621,5 +625,18 @@ class IncrementalInstallTest(unittest.TestCase):
except SystemExit:
pass
+ def testSdkTooOld(self):
+ self._mock_adb.SetError(
+ 0, "INSTALL_FAILED_OLDER_SDK", "", for_arg="install")
+ self._CreateZip()
+ self._CreateLocalManifest("zip1 zp1 ip1 0")
+ try:
+ self._CallIncrementalInstall(incremental=False)
+ self.fail("Should have quit if the SDK is too old.")
+ except SystemExit as e:
+ # make sure it's the right SystemExit reason
+ self.assertTrue("minSdkVersion" in str(e))
+
+
if __name__ == "__main__":
unittest.main()