Commit 421258ba authored by Jakob Andersen's avatar Jakob Andersen Committed by GitHub

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
parent 2888139c
...@@ -196,10 +196,6 @@ class AndroidDevice extends Device { ...@@ -196,10 +196,6 @@ class AndroidDevice extends Device {
return '/data/local/tmp/sky.${app.id}.sha1'; return '/data/local/tmp/sky.${app.id}.sha1';
} }
String _getDeviceApkSha1(ApplicationPackage app) {
return runCheckedSync(adbCommandForDevice(<String>['shell', 'cat', _getDeviceSha1Path(app)]));
}
String _getSourceSha1(ApplicationPackage app) { String _getSourceSha1(ApplicationPackage app) {
AndroidApk apk = app; AndroidApk apk = app;
File shaFile = fs.file('${apk.apkPath}.sha1'); File shaFile = fs.file('${apk.apkPath}.sha1');
...@@ -213,11 +209,7 @@ class AndroidDevice extends Device { ...@@ -213,11 +209,7 @@ class AndroidDevice extends Device {
bool isAppInstalled(ApplicationPackage app) { bool isAppInstalled(ApplicationPackage app) {
// This call takes 400ms - 600ms. // This call takes 400ms - 600ms.
String listOut = runCheckedSync(adbCommandForDevice(<String>['shell', 'pm', 'list', 'packages', app.id])); String listOut = runCheckedSync(adbCommandForDevice(<String>['shell', 'pm', 'list', 'packages', app.id]));
if (!LineSplitter.split(listOut).contains("package:${app.id}")) return LineSplitter.split(listOut).contains("package:${app.id}");
return false;
// Check the application SHA.
return _getDeviceApkSha1(app) == _getSourceSha1(app);
} }
@override @override
......
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