Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1805)

Unified Diff: build/android/gyp/apk_install.py

Issue 2069113002: [build/android] Switch hand-rolled 'ls' to StatDirectory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | build/android/gyp/util/build_device.py » ('j') | build/android/gyp/util/build_device.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/gyp/apk_install.py
diff --git a/build/android/gyp/apk_install.py b/build/android/gyp/apk_install.py
index 9c9076384c8baf3252302feb4542df58cd18c0e4..f43b0a177377dd84665d3d07aecd94c7fb0c94d7 100755
--- a/build/android/gyp/apk_install.py
+++ b/build/android/gyp/apk_install.py
@@ -10,7 +10,6 @@
import optparse
import os
-import re
import sys
from util import build_device
@@ -26,35 +25,26 @@ from devil.android import apk_helper
from pylib import constants
-def GetNewMetadata(device, apk_package):
- """Gets the metadata on the device for the apk_package apk."""
- output = device.RunShellCommand('ls -l /data/app/')
- # Matches lines like:
- # -rw-r--r-- system system 7376582 2013-04-19 16:34 \
- # org.chromium.chrome.apk
- # -rw-r--r-- system system 7376582 2013-04-19 16:34 \
- # org.chromium.chrome-1.apk
- apk_matcher = lambda s: re.match('.*%s(-[0-9]*)?(.apk)?$' % apk_package, s)
- matches = filter(apk_matcher, output)
- return matches[0] if matches else None
perezju 2016/06/15 14:54:45 Replaced below with device.GetInstallMetadata(apk_
-
def HasInstallMetadataChanged(device, apk_package, metadata_path):
"""Checks if the metadata on the device for apk_package has changed."""
if not os.path.exists(metadata_path):
return True
- with open(metadata_path, 'r') as expected_file:
- return expected_file.read() != device.GetInstallMetadata(apk_package)
+ try:
+ expected_metadata = build_utils.ReadJson(metadata_path)
+ except ValueError: # File is not json encoded.
+ return True
perezju 2016/06/15 14:54:45 Give some tolerance for old files (with the output
agrieve 2016/06/15 17:25:24 One step even better would be to change this file
perezju 2016/06/16 09:31:28 Had a quick look, but the change would be a bit mo
+
+ return expected_metadata != device.GetInstallMetadata(apk_package)
def RecordInstallMetadata(device, apk_package, metadata_path):
"""Records the metadata from the device for apk_package."""
- metadata = GetNewMetadata(device, apk_package)
+ metadata = device.GetInstallMetadata(apk_package, refresh=True)
if not metadata:
raise Exception('APK install failed unexpectedly.')
- with open(metadata_path, 'w') as outfile:
- outfile.write(metadata)
+ build_utils.WriteJson(metadata, metadata_path)
def main():
« no previous file with comments | « no previous file | build/android/gyp/util/build_device.py » ('j') | build/android/gyp/util/build_device.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698