Commit a1230352 authored by Andrew Grieve's avatar Andrew Grieve Committed by Commit Bot

apk_operations.py: Minor bugfixes to disk-usage command

* Fix exception when not using a wrapper script
* Fix stripping "Hidden system packages" (does not always come last)
* Fix error message when package does not exist (on newer OS's)
* Add a warning when measuring a system apks

Change-Id: I0b43993e3b28f723899d236f43365e2d954607bb
Reviewed-on: https://chromium-review.googlesource.com/c/1281104Reviewed-by: default avatarEric Stevenson <estevenson@chromium.org>
Commit-Queue: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#599884}
parent 8ec7790a
......@@ -391,13 +391,13 @@ def _RunDiskUsage(devices, package_name, verbose):
def disk_usage_helper(d):
package_output = '\n'.join(d.RunShellCommand(
['dumpsys', 'package', package_name], check_return=True))
# Prints a message but does not return error when apk is not installed.
if 'Unable to find package:' in package_output:
# Does not return error when apk is not installed.
if not package_output or 'Unable to find package:' in package_output:
return None
# Ignore system apks.
idx = package_output.find('Hidden system packages:')
if idx != -1:
package_output = package_output[:idx]
# Ignore system apks that have updates installed.
package_output = re.sub(r'Hidden system packages:.*?^\b', '',
package_output, flags=re.S | re.M)
try:
data_dir = re.search(r'dataDir=(.*)', package_output).group(1)
......@@ -406,6 +406,10 @@ def _RunDiskUsage(devices, package_name, verbose):
package_output).group(1)
except AttributeError:
raise Exception('Error parsing dumpsys output: ' + package_output)
if code_path.startswith('/system'):
logging.warning('Measurement of system image apks can be innacurate')
compilation_filters = set()
# Match "compilation_filter=value", where a line break can occur at any spot
# (refer to examples above).
......@@ -952,7 +956,9 @@ class _Command(object):
self.devices = []
if self.need_device_args:
# See https://crbug.com/887964 regarding bundle support in apk_helper.
abis = self.apk_helper.GetAbis() if not self.is_bundle else None
abis = None
if not self.is_bundle and self.apk_helper is not None:
abis = self.apk_helper.GetAbis()
self.devices = device_utils.DeviceUtils.HealthyDevices(
device_arg=args.devices,
enable_device_files_cache=bool(args.output_directory),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment