diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index b1d94d2d6a..527e9e2268 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -406,17 +406,12 @@ class AndroidDevice extends Device { if (!await _adbIsValid) { return false; } - final bool wasInstalled = await isAppInstalled(app, userIdentifier: userIdentifier); - if (wasInstalled && await isLatestBuildInstalled(app)) { - _logger.printTrace('Latest build already installed.'); - return true; - } _logger.printTrace('Installing APK.'); if (await _installApp(app, userIdentifier: userIdentifier)) { return true; } _logger.printTrace('Warning: Failed to install APK.'); - if (!wasInstalled) { + if (!await isAppInstalled(app, userIdentifier: userIdentifier)) { return false; } _logger.printStatus('Uninstalling old version...'); diff --git a/packages/flutter_tools/test/general.shard/android/android_device_start_test.dart b/packages/flutter_tools/test/general.shard/android/android_device_start_test.dart index 506a777df4..690e6dd1fb 100644 --- a/packages/flutter_tools/test/general.shard/android/android_device_start_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_device_start_test.dart @@ -87,11 +87,6 @@ void main() { command: ['adb', '-s', '1234', 'shell', 'am', 'force-stop', 'FlutterApp'], ), ); - processManager.addCommand( - const FakeCommand( - command: ['adb', '-s', '1234', 'shell', 'pm', 'list', 'packages', 'FlutterApp'], - ), - ); processManager.addCommand( const FakeCommand( command: ['adb', '-s', '1234', 'install', '-t', '-r', 'app-debug.apk'], @@ -212,22 +207,6 @@ void main() { ], ), ); - processManager.addCommand( - const FakeCommand( - command: [ - 'adb', - '-s', - '1234', - 'shell', - 'pm', - 'list', - 'packages', - '--user', - '10', - 'FlutterApp', - ], - ), - ); processManager.addCommand( const FakeCommand( command: [ diff --git a/packages/flutter_tools/test/general.shard/android/android_install_test.dart b/packages/flutter_tools/test/general.shard/android/android_install_test.dart index c36a3a4e58..991b0804e3 100644 --- a/packages/flutter_tools/test/general.shard/android/android_install_test.dart +++ b/packages/flutter_tools/test/general.shard/android/android_install_test.dart @@ -101,21 +101,6 @@ void main() { command: ['adb', '-s', '1234', 'shell', 'getprop'], stdout: '[ro.build.version.sdk]: [16]', ), - const FakeCommand( - command: [ - 'adb', - '-s', - '1234', - 'shell', - 'pm', - 'list', - 'packages', - '--user', - '10', - 'app', - ], - stdout: '\n', - ), kInstallCommand, kStoreShaCommand, ]); @@ -137,21 +122,6 @@ void main() { kAdbVersionCommand, kAdbStartServerCommand, const FakeCommand(command: ['adb', '-s', '1234', 'shell', 'getprop']), - const FakeCommand( - command: [ - 'adb', - '-s', - '1234', - 'shell', - 'pm', - 'list', - 'packages', - '--user', - '10', - 'app', - ], - stdout: '\n', - ), kInstallCommand, kStoreShaCommand, ]); @@ -174,22 +144,6 @@ void main() { kAdbStartServerCommand, const FakeCommand(command: ['adb', '-s', '1234', 'shell', 'getprop']), // This command is run before the user is checked and is allowed to fail. - const FakeCommand( - command: [ - 'adb', - '-s', - '1234', - 'shell', - 'pm', - 'list', - 'packages', - '--user', - 'jane', - 'app', - ], - stderr: 'Blah blah', - exitCode: 1, - ), const FakeCommand( command: [ 'adb', @@ -204,7 +158,9 @@ void main() { ], exitCode: 1, stderr: - 'Exception occurred while executing: java.lang.IllegalArgumentException: Bad user number: jane', + 'Exception occurred while executing: ' + 'java.lang.IllegalArgumentException: ' + 'Bad user number: jane', ), ]); final File apk = fileSystem.file('app-debug.apk')..createSync(); @@ -220,13 +176,14 @@ void main() { expect( logger.errorText, contains( - 'Error: User "jane" not found. Run "adb shell pm list users" to see list of available identifiers.', + 'Error: User "jane" not found. Run "adb shell pm list users" ' + 'to see list of available identifiers.', ), ); expect(processManager, hasNoRemainingExpectations); }); - testWithoutContext('Will skip install if the correct version is up to date', () async { + testWithoutContext('Will continue install if the correct version is up to date', () async { final FakeProcessManager processManager = FakeProcessManager.list([ kAdbVersionCommand, kAdbStartServerCommand, @@ -234,23 +191,19 @@ void main() { command: ['adb', '-s', '1234', 'shell', 'getprop'], stdout: '[ro.build.version.sdk]: [16]', ), + kInstallCommand, const FakeCommand( command: [ 'adb', '-s', '1234', 'shell', - 'pm', - 'list', - 'packages', - '--user', - '10', - 'app', + 'echo', + '-n', + 'example_sha', + '>', + '/data/local/tmp/sky.app.sha1', ], - stdout: 'package:app\n', - ), - const FakeCommand( - command: ['adb', '-s', '1234', 'shell', 'cat', '/data/local/tmp/sky.app.sha1'], stdout: 'example_sha', ), ]); @@ -278,25 +231,6 @@ void main() { command: ['adb', '-s', '1234', 'shell', 'getprop'], stdout: '[ro.build.version.sdk]: [16]', ), - const FakeCommand( - command: [ - 'adb', - '-s', - '1234', - 'shell', - 'pm', - 'list', - 'packages', - '--user', - '10', - 'app', - ], - stdout: 'package:app\n', - ), - const FakeCommand( - command: ['adb', '-s', '1234', 'shell', 'cat', '/data/local/tmp/sky.app.sha1'], - stdout: 'different_example_sha', - ), const FakeCommand( command: [ 'adb', @@ -312,6 +246,21 @@ void main() { exitCode: 1, stderr: '[INSTALL_FAILED_INSUFFICIENT_STORAGE]', ), + const FakeCommand( + command: [ + 'adb', + '-s', + '1234', + 'shell', + 'pm', + 'list', + 'packages', + '--user', + '10', + 'app', + ], + stdout: 'package:app\n', + ), const FakeCommand( command: ['adb', '-s', '1234', 'uninstall', '--user', '10', 'app'], ), @@ -355,21 +304,6 @@ void main() { command: ['adb', '-s', '1234', 'shell', 'getprop'], stdout: '[ro.build.version.sdk]: [16]', ), - const FakeCommand( - command: [ - 'adb', - '-s', - '1234', - 'shell', - 'pm', - 'list', - 'packages', - '--user', - '10', - 'app', - ], - stdout: '\n', - ), const FakeCommand( command: [ 'adb',