Unverified Commit bd6ccb60 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter_tools] android device stopApp handles null apk (#55990)

The resident runner does not check if the ApplicationPackage is null when trying to stop the app. Update AndroidDevice.stopApp to handle this case by returning false.

The package will be null when flutter attach is used.
parent fdc6f38a
...@@ -647,6 +647,9 @@ class AndroidDevice extends Device { ...@@ -647,6 +647,9 @@ class AndroidDevice extends Device {
@override @override
Future<bool> stopApp(AndroidApk app) { Future<bool> stopApp(AndroidApk app) {
if (app == null) {
return Future<bool>.value(false);
}
final List<String> command = adbCommandForDevice(<String>['shell', 'am', 'force-stop', app.id]); final List<String> command = adbCommandForDevice(<String>['shell', 'am', 'force-stop', app.id]);
return processUtils.stream(command).then<bool>( return processUtils.stream(command).then<bool>(
(int exitCode) => exitCode == 0 || allowHeapCorruptionOnWindows(exitCode)); (int exitCode) => exitCode == 0 || allowHeapCorruptionOnWindows(exitCode));
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter_tools/src/android/android_device.dart';
import '../../src/common.dart';
void main() {
testWithoutContext('AndroidDevice.stopApp handles a null ApplicationPackage', () async {
final AndroidDevice androidDevice = AndroidDevice('2');
expect(await androidDevice.stopApp(null), false);
});
}
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