From 421258baea8d2102ae92f93c59f982f188e2aad8 Mon Sep 17 00:00:00 2001 From: Jakob Andersen Date: Tue, 21 Feb 2017 10:18:12 +0100 Subject: [PATCH] Remove SHA1 check from AndroidDevice.isAppInstalled() (#8290) * Remove SHA1 check from AndroidDevice.isAppInstalled() The docs for isAppInstalled say 'check if a version of the given app is already installed', however the current code returns true only if it's the latest build that's installed. This made sense in the past, when the use pattern was: if (!isAppInstalled(...)) installApp(...); but now the usage is: if (isAppInstalled(...)) uninstallApp(...); installApp(...); This has the probably unintended consequence that if you run `flutter install` or `flutter run` two times in a row with no source changes, the second invocation will uninstall the app, but the first invocation might not. Removing the SHA1 check makes us always uninstall the app if it's installed. Fixes #8172 --- .../flutter_tools/lib/src/android/android_device.dart | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index f4f565f337..e74f7884ec 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -196,10 +196,6 @@ class AndroidDevice extends Device { return '/data/local/tmp/sky.${app.id}.sha1'; } - String _getDeviceApkSha1(ApplicationPackage app) { - return runCheckedSync(adbCommandForDevice(['shell', 'cat', _getDeviceSha1Path(app)])); - } - String _getSourceSha1(ApplicationPackage app) { AndroidApk apk = app; File shaFile = fs.file('${apk.apkPath}.sha1'); @@ -213,11 +209,7 @@ class AndroidDevice extends Device { bool isAppInstalled(ApplicationPackage app) { // This call takes 400ms - 600ms. String listOut = runCheckedSync(adbCommandForDevice(['shell', 'pm', 'list', 'packages', app.id])); - if (!LineSplitter.split(listOut).contains("package:${app.id}")) - return false; - - // Check the application SHA. - return _getDeviceApkSha1(app) == _getSourceSha1(app); + return LineSplitter.split(listOut).contains("package:${app.id}"); } @override