Audit covariant usage in tool (#116930)

This commit is contained in:
Jenn Magder 2022-12-15 11:59:34 -08:00 committed by GitHub
parent f1d157bc29
commit ada4460502
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 125 additions and 123 deletions

View File

@ -366,7 +366,7 @@ class AndroidDevice extends Device {
@override @override
Future<bool> isAppInstalled( Future<bool> isAppInstalled(
AndroidApk app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
// This call takes 400ms - 600ms. // This call takes 400ms - 600ms.
@ -388,14 +388,14 @@ class AndroidDevice extends Device {
} }
@override @override
Future<bool> isLatestBuildInstalled(AndroidApk app) async { Future<bool> isLatestBuildInstalled(covariant AndroidApk app) async {
final String installedSha1 = await _getDeviceApkSha1(app); final String installedSha1 = await _getDeviceApkSha1(app);
return installedSha1.isNotEmpty && installedSha1 == _getSourceSha1(app); return installedSha1.isNotEmpty && installedSha1 == _getSourceSha1(app);
} }
@override @override
Future<bool> installApp( Future<bool> installApp(
AndroidApk app, { covariant AndroidApk app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
if (!await _adbIsValid) { if (!await _adbIsValid) {
@ -478,7 +478,7 @@ class AndroidDevice extends Device {
@override @override
Future<bool> uninstallApp( Future<bool> uninstallApp(
AndroidApk app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
if (!await _adbIsValid) { if (!await _adbIsValid) {
@ -519,7 +519,7 @@ class AndroidDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
AndroidApk package, { AndroidApk? package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
@ -721,11 +721,11 @@ class AndroidDevice extends Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
AndroidApk? app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) { }) async {
if (app == null) { if (app == null) {
return Future<bool>.value(false); return false;
} }
final List<String> command = adbCommandForDevice(<String>[ final List<String> command = adbCommandForDevice(<String>[
'shell', 'shell',
@ -767,7 +767,7 @@ class AndroidDevice extends Device {
@override @override
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
AndroidApk? app, ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}) async { }) async {
// The Android log reader isn't app-specific. The `app` parameter isn't used. // The Android log reader isn't app-specific. The `app` parameter isn't used.

View File

@ -475,7 +475,7 @@ class CustomDevice extends Device {
@override @override
final DevicePortForwarder portForwarder; final DevicePortForwarder portForwarder;
CustomDeviceAppSession _getOrCreateAppSession(covariant ApplicationPackage app) { CustomDeviceAppSession _getOrCreateAppSession(ApplicationPackage app) {
return _sessions.putIfAbsent( return _sessions.putIfAbsent(
app, app,
() { () {
@ -663,7 +663,7 @@ class CustomDevice extends Device {
@override @override
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
covariant ApplicationPackage? app, ApplicationPackage? app,
bool includePastLogs = false bool includePastLogs = false
}) { }) {
if (app != null) { if (app != null) {
@ -674,7 +674,7 @@ class CustomDevice extends Device {
} }
@override @override
Future<bool> installApp(covariant ApplicationPackage app, {String? userIdentifier}) async { Future<bool> installApp(ApplicationPackage app, {String? userIdentifier}) async {
final String? appName = app.name; final String? appName = app.name;
if (appName == null || !await tryUninstall(appName: appName)) { if (appName == null || !await tryUninstall(appName: appName)) {
return false; return false;
@ -689,12 +689,12 @@ class CustomDevice extends Device {
} }
@override @override
Future<bool> isAppInstalled(covariant ApplicationPackage app, {String? userIdentifier}) async { Future<bool> isAppInstalled(ApplicationPackage app, {String? userIdentifier}) async {
return false; return false;
} }
@override @override
Future<bool> isLatestBuildInstalled(covariant ApplicationPackage app) async { Future<bool> isLatestBuildInstalled(ApplicationPackage app) async {
return false; return false;
} }
@ -742,7 +742,7 @@ class CustomDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
covariant ApplicationPackage package, { ApplicationPackage package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
@ -796,7 +796,10 @@ class CustomDevice extends Device {
} }
@override @override
Future<bool> stopApp(covariant ApplicationPackage app, {String? userIdentifier}) { Future<bool> stopApp(ApplicationPackage? app, {String? userIdentifier}) async {
if (app == null) {
return false;
}
return _getOrCreateAppSession(app).stop(); return _getOrCreateAppSession(app).stop();
} }
@ -804,7 +807,7 @@ class CustomDevice extends Device {
Future<TargetPlatform> get targetPlatform async => _config.platform ?? TargetPlatform.linux_arm64; Future<TargetPlatform> get targetPlatform async => _config.platform ?? TargetPlatform.linux_arm64;
@override @override
Future<bool> uninstallApp(covariant ApplicationPackage app, {String? userIdentifier}) async { Future<bool> uninstallApp(ApplicationPackage app, {String? userIdentifier}) async {
final String? appName = app.name; final String? appName = app.name;
if (appName == null) { if (appName == null) {
return false; return false;

View File

@ -44,7 +44,7 @@ abstract class DesktopDevice extends Device {
final DesktopLogReader _deviceLogReader = DesktopLogReader(); final DesktopLogReader _deviceLogReader = DesktopLogReader();
@override @override
DevFSWriter createDevFSWriter(covariant ApplicationPackage? app, String? userIdentifier) { DevFSWriter createDevFSWriter(ApplicationPackage? app, String? userIdentifier) {
return LocalDevFSWriter(fileSystem: _fileSystem); return LocalDevFSWriter(fileSystem: _fileSystem);
} }
@ -117,7 +117,6 @@ abstract class DesktopDevice extends Device {
}) async { }) async {
if (!prebuiltApplication) { if (!prebuiltApplication) {
await buildForDevice( await buildForDevice(
package,
buildInfo: debuggingOptions.buildInfo, buildInfo: debuggingOptions.buildInfo,
mainPath: mainPath, mainPath: mainPath,
); );
@ -179,7 +178,7 @@ abstract class DesktopDevice extends Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
ApplicationPackage app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
bool succeeded = true; bool succeeded = true;
@ -197,8 +196,7 @@ abstract class DesktopDevice extends Device {
} }
/// Builds the current project for this device, with the given options. /// Builds the current project for this device, with the given options.
Future<void> buildForDevice( Future<void> buildForDevice({
ApplicationPackage package, {
required BuildInfo buildInfo, required BuildInfo buildInfo,
String? mainPath, String? mainPath,
}); });

View File

@ -470,18 +470,18 @@ abstract class Device {
/// ///
/// Specify [userIdentifier] to check if installed for a particular user (Android only). /// Specify [userIdentifier] to check if installed for a particular user (Android only).
Future<bool> isAppInstalled( Future<bool> isAppInstalled(
covariant ApplicationPackage app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}); });
/// Check if the latest build of the [app] is already installed. /// Check if the latest build of the [app] is already installed.
Future<bool> isLatestBuildInstalled(covariant ApplicationPackage app); Future<bool> isLatestBuildInstalled(ApplicationPackage app);
/// Install an app package on the current device. /// Install an app package on the current device.
/// ///
/// Specify [userIdentifier] to install for a particular user (Android only). /// Specify [userIdentifier] to install for a particular user (Android only).
Future<bool> installApp( Future<bool> installApp(
covariant ApplicationPackage app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}); });
@ -490,7 +490,7 @@ abstract class Device {
/// Specify [userIdentifier] to uninstall for a particular user, /// Specify [userIdentifier] to uninstall for a particular user,
/// defaults to all users (Android only). /// defaults to all users (Android only).
Future<bool> uninstallApp( Future<bool> uninstallApp(
covariant ApplicationPackage app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}); });
@ -516,7 +516,7 @@ abstract class Device {
/// For example, the desktop device classes can use a writer which /// For example, the desktop device classes can use a writer which
/// copies the files across the local file system. /// copies the files across the local file system.
DevFSWriter? createDevFSWriter( DevFSWriter? createDevFSWriter(
covariant ApplicationPackage? app, ApplicationPackage? app,
String? userIdentifier, String? userIdentifier,
) { ) {
return null; return null;
@ -531,7 +531,7 @@ abstract class Device {
/// reader will also include log messages from before the invocation time. /// reader will also include log messages from before the invocation time.
/// Defaults to false. /// Defaults to false.
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
covariant ApplicationPackage? app, ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}); });
@ -583,7 +583,7 @@ abstract class Device {
/// ///
/// Specify [userIdentifier] to stop app installed to a profile (Android only). /// Specify [userIdentifier] to stop app installed to a profile (Android only).
Future<bool> stopApp( Future<bool> stopApp(
covariant ApplicationPackage? app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}); });

View File

@ -296,11 +296,12 @@ class FlutterDriverService extends DriverService {
await sharedSkSlWriter(_device!, result, outputFile: writeSkslOnExit, logger: _logger); await sharedSkSlWriter(_device!, result, outputFile: writeSkslOnExit, logger: _logger);
} }
// If the application package is available, stop and uninstall. // If the application package is available, stop and uninstall.
if (_applicationPackage != null) { final ApplicationPackage? package = _applicationPackage;
if (!await _device!.stopApp(_applicationPackage, userIdentifier: userIdentifier)) { if (package != null) {
if (!await _device!.stopApp(package, userIdentifier: userIdentifier)) {
_logger.printError('Failed to stop app'); _logger.printError('Failed to stop app');
} }
if (!await _device!.uninstallApp(_applicationPackage!, userIdentifier: userIdentifier)) { if (!await _device!.uninstallApp(package, userIdentifier: userIdentifier)) {
_logger.printError('Failed to uninstall app'); _logger.printError('Failed to uninstall app');
} }
} else if (_device!.supportsFlutterExit) { } else if (_device!.supportsFlutterExit) {

View File

@ -293,7 +293,7 @@ class FuchsiaDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
covariant FuchsiaApp package, { FuchsiaApp package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
@ -471,7 +471,7 @@ class FuchsiaDevice extends Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
covariant FuchsiaApp app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
if (await isSession) { if (await isSession) {

View File

@ -8,6 +8,7 @@ import 'package:meta/meta.dart';
import 'package:process/process.dart'; import 'package:process/process.dart';
import 'package:vm_service/vm_service.dart' as vm_service; import 'package:vm_service/vm_service.dart' as vm_service;
import '../application_package.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/logger.dart'; import '../base/logger.dart';
@ -225,7 +226,7 @@ class IOSDevice extends Device {
@override @override
Future<bool> isAppInstalled( Future<bool> isAppInstalled(
IOSApp app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
bool result; bool result;
@ -242,11 +243,11 @@ class IOSDevice extends Device {
} }
@override @override
Future<bool> isLatestBuildInstalled(IOSApp app) async => false; Future<bool> isLatestBuildInstalled(ApplicationPackage app) async => false;
@override @override
Future<bool> installApp( Future<bool> installApp(
IOSApp app, { covariant IOSApp app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
final Directory bundle = _fileSystem.directory(app.deviceBundlePath); final Directory bundle = _fileSystem.directory(app.deviceBundlePath);
@ -280,7 +281,7 @@ class IOSDevice extends Device {
@override @override
Future<bool> uninstallApp( Future<bool> uninstallApp(
IOSApp app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
int uninstallationResult; int uninstallationResult;
@ -434,7 +435,7 @@ class IOSDevice extends Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
IOSApp app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
// If the debugger is not attached, killing the ios-deploy process won't stop the app. // If the debugger is not attached, killing the ios-deploy process won't stop the app.
@ -453,7 +454,7 @@ class IOSDevice extends Device {
@override @override
DeviceLogReader getLogReader({ DeviceLogReader getLogReader({
IOSApp? app, covariant IOSApp? app,
bool includePastLogs = false, bool includePastLogs = false,
}) { }) {
assert(!includePastLogs, 'Past log reading not supported on iOS devices.'); assert(!includePastLogs, 'Past log reading not supported on iOS devices.');

View File

@ -327,7 +327,7 @@ class IOSSimulator extends Device {
final SimControl _simControl; final SimControl _simControl;
@override @override
DevFSWriter createDevFSWriter(covariant ApplicationPackage? app, String? userIdentifier) { DevFSWriter createDevFSWriter(ApplicationPackage? app, String? userIdentifier) {
return LocalDevFSWriter(fileSystem: globals.fs); return LocalDevFSWriter(fileSystem: globals.fs);
} }
@ -369,8 +369,7 @@ class IOSSimulator extends Device {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
try { try {
final IOSApp iosApp = app; await _simControl.install(id, app.simulatorBundlePath);
await _simControl.install(id, iosApp.simulatorBundlePath);
return true; return true;
} on Exception { } on Exception {
return false; return false;
@ -420,7 +419,7 @@ class IOSSimulator extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
covariant IOSApp package, { IOSApp package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
@ -506,7 +505,7 @@ class IOSSimulator extends Device {
return LaunchResult.failed(); return LaunchResult.failed();
} }
Future<void> _setupUpdatedApplicationBundle(covariant BuildableIOSApp app, BuildInfo buildInfo, String? mainPath) async { Future<void> _setupUpdatedApplicationBundle(BuildableIOSApp app, BuildInfo buildInfo, String? mainPath) async {
// Step 1: Build the Xcode project. // Step 1: Build the Xcode project.
// The build mode for the simulator is always debug. // The build mode for the simulator is always debug.
assert(buildInfo.isDebug); assert(buildInfo.isDebug);
@ -574,7 +573,7 @@ class IOSSimulator extends Device {
@override @override
DeviceLogReader getLogReader({ DeviceLogReader getLogReader({
IOSApp? app, covariant IOSApp? app,
bool includePastLogs = false, bool includePastLogs = false,
}) { }) {
assert(!includePastLogs, 'Past log reading not supported on iOS simulators.'); assert(!includePastLogs, 'Past log reading not supported on iOS simulators.');

View File

@ -57,8 +57,7 @@ class LinuxDevice extends DesktopDevice {
} }
@override @override
Future<void> buildForDevice( Future<void> buildForDevice({
covariant LinuxApp package, {
String? mainPath, String? mainPath,
required BuildInfo buildInfo, required BuildInfo buildInfo,
}) async { }) async {

View File

@ -65,8 +65,7 @@ class MacOSDevice extends DesktopDevice {
} }
@override @override
Future<void> buildForDevice( Future<void> buildForDevice({
covariant MacOSApp package, {
required BuildInfo buildInfo, required BuildInfo buildInfo,
String? mainPath, String? mainPath,
}) async { }) async {

View File

@ -14,7 +14,6 @@ import '../base/platform.dart';
import '../build_info.dart'; import '../build_info.dart';
import '../desktop_device.dart'; import '../desktop_device.dart';
import '../device.dart'; import '../device.dart';
import '../ios/application_package.dart';
import '../ios/ios_workflow.dart'; import '../ios/ios_workflow.dart';
import '../project.dart'; import '../project.dart';
@ -59,7 +58,7 @@ class MacOSDesignedForIPadDevice extends DesktopDevice {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
IOSApp package, { ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
@ -74,13 +73,12 @@ class MacOSDesignedForIPadDevice extends DesktopDevice {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
IOSApp app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async => false; }) async => false;
@override @override
Future<void> buildForDevice( Future<void> buildForDevice({
covariant IOSApp package, {
String? mainPath, String? mainPath,
required BuildInfo buildInfo, required BuildInfo buildInfo,
}) async { }) async {

View File

@ -65,16 +65,16 @@ class PreviewDevice extends Device {
final DesktopLogReader _logReader = DesktopLogReader(); final DesktopLogReader _logReader = DesktopLogReader();
@override @override
FutureOr<DeviceLogReader> getLogReader({covariant ApplicationPackage? app, bool includePastLogs = false}) => _logReader; FutureOr<DeviceLogReader> getLogReader({ApplicationPackage? app, bool includePastLogs = false}) => _logReader;
@override @override
Future<bool> installApp(covariant ApplicationPackage? app, {String? userIdentifier}) async => true; Future<bool> installApp(ApplicationPackage? app, {String? userIdentifier}) async => true;
@override @override
Future<bool> isAppInstalled(covariant ApplicationPackage app, {String? userIdentifier}) async => false; Future<bool> isAppInstalled(ApplicationPackage app, {String? userIdentifier}) async => false;
@override @override
Future<bool> isLatestBuildInstalled(covariant ApplicationPackage app) async => false; Future<bool> isLatestBuildInstalled(ApplicationPackage app) async => false;
@override @override
Future<bool> get isLocalEmulator async => false; Future<bool> get isLocalEmulator async => false;
@ -97,7 +97,7 @@ class PreviewDevice extends Device {
Process? _process; Process? _process;
@override @override
Future<LaunchResult> startApp(covariant ApplicationPackage package, { Future<LaunchResult> startApp(ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
@ -163,7 +163,7 @@ class PreviewDevice extends Device {
} }
@override @override
Future<bool> stopApp(covariant ApplicationPackage app, {String? userIdentifier}) async { Future<bool> stopApp(ApplicationPackage? app, {String? userIdentifier}) async {
return _process?.kill() ?? false; return _process?.kill() ?? false;
} }
@ -176,12 +176,12 @@ class PreviewDevice extends Device {
} }
@override @override
Future<bool> uninstallApp(covariant ApplicationPackage app, {String? userIdentifier}) async { Future<bool> uninstallApp(ApplicationPackage app, {String? userIdentifier}) async {
return true; return true;
} }
@override @override
DevFSWriter createDevFSWriter(covariant ApplicationPackage? app, String? userIdentifier) { DevFSWriter createDevFSWriter(ApplicationPackage? app, String? userIdentifier) {
return LocalDevFSWriter(fileSystem: _fileSystem); return LocalDevFSWriter(fileSystem: _fileSystem);
} }
} }

View File

@ -172,22 +172,22 @@ class ProxiedDevice extends Device {
@override @override
Future<bool> isAppInstalled( Future<bool> isAppInstalled(
covariant ApplicationPackage app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) => throw UnimplementedError(); }) => throw UnimplementedError();
@override @override
Future<bool> isLatestBuildInstalled(covariant ApplicationPackage app) => throw UnimplementedError(); Future<bool> isLatestBuildInstalled(ApplicationPackage app) => throw UnimplementedError();
@override @override
Future<bool> installApp( Future<bool> installApp(
covariant ApplicationPackage app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) => throw UnimplementedError(); }) => throw UnimplementedError();
@override @override
Future<bool> uninstallApp( Future<bool> uninstallApp(
covariant ApplicationPackage app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) => throw UnimplementedError(); }) => throw UnimplementedError();
@ -224,7 +224,7 @@ class ProxiedDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
covariant PrebuiltApplicationPackage package, { PrebuiltApplicationPackage package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,

View File

@ -424,8 +424,9 @@ class FlutterDevice {
buildInfo: hotRunner.debuggingOptions.buildInfo, buildInfo: hotRunner.debuggingOptions.buildInfo,
applicationBinary: hotRunner.applicationBinary, applicationBinary: hotRunner.applicationBinary,
); );
final ApplicationPackage? applicationPackage = package;
if (package == null) { if (applicationPackage == null) {
String message = 'No application found for $targetPlatform.'; String message = 'No application found for $targetPlatform.';
final String? hint = await getMissingPackageHintForPlatform(targetPlatform); final String? hint = await getMissingPackageHintForPlatform(targetPlatform);
if (hint != null) { if (hint != null) {
@ -434,7 +435,7 @@ class FlutterDevice {
globals.printError(message); globals.printError(message);
return 1; return 1;
} }
devFSWriter = device!.createDevFSWriter(package, userIdentifier); devFSWriter = device!.createDevFSWriter(applicationPackage, userIdentifier);
final Map<String, dynamic> platformArgs = <String, dynamic>{ final Map<String, dynamic> platformArgs = <String, dynamic>{
'multidex': hotRunner.multidexEnabled, 'multidex': hotRunner.multidexEnabled,
@ -444,7 +445,7 @@ class FlutterDevice {
// Start the application. // Start the application.
final Future<LaunchResult> futureResult = device!.startApp( final Future<LaunchResult> futureResult = device!.startApp(
package, applicationPackage,
mainPath: hotRunner.mainPath, mainPath: hotRunner.mainPath,
debuggingOptions: hotRunner.debuggingOptions, debuggingOptions: hotRunner.debuggingOptions,
platformArgs: platformArgs, platformArgs: platformArgs,
@ -483,24 +484,9 @@ class FlutterDevice {
buildInfo: coldRunner.debuggingOptions.buildInfo, buildInfo: coldRunner.debuggingOptions.buildInfo,
applicationBinary: coldRunner.applicationBinary, applicationBinary: coldRunner.applicationBinary,
); );
devFSWriter = device!.createDevFSWriter(package, userIdentifier); final ApplicationPackage? applicationPackage = package;
final String modeName = coldRunner.debuggingOptions.buildInfo.friendlyModeName; if (applicationPackage == null) {
final bool prebuiltMode = coldRunner.applicationBinary != null;
if (coldRunner.mainPath == null) {
assert(prebuiltMode);
globals.printStatus(
'Launching ${package!.displayName} '
'on ${device!.name} in $modeName mode...',
);
} else {
globals.printStatus(
'Launching ${getDisplayPath(coldRunner.mainPath, globals.fs)} '
'on ${device!.name} in $modeName mode...',
);
}
if (package == null) {
String message = 'No application found for $targetPlatform.'; String message = 'No application found for $targetPlatform.';
final String? hint = await getMissingPackageHintForPlatform(targetPlatform); final String? hint = await getMissingPackageHintForPlatform(targetPlatform);
if (hint != null) { if (hint != null) {
@ -510,6 +496,23 @@ class FlutterDevice {
return 1; return 1;
} }
devFSWriter = device!.createDevFSWriter(applicationPackage, userIdentifier);
final String modeName = coldRunner.debuggingOptions.buildInfo.friendlyModeName;
final bool prebuiltMode = coldRunner.applicationBinary != null;
if (coldRunner.mainPath == null) {
assert(prebuiltMode);
globals.printStatus(
'Launching ${applicationPackage.displayName} '
'on ${device!.name} in $modeName mode...',
);
} else {
globals.printStatus(
'Launching ${getDisplayPath(coldRunner.mainPath, globals.fs)} '
'on ${device!.name} in $modeName mode...',
);
}
final Map<String, dynamic> platformArgs = <String, dynamic>{}; final Map<String, dynamic> platformArgs = <String, dynamic>{};
if (coldRunner.traceStartup != null) { if (coldRunner.traceStartup != null) {
platformArgs['trace-startup'] = coldRunner.traceStartup; platformArgs['trace-startup'] = coldRunner.traceStartup;
@ -519,7 +522,7 @@ class FlutterDevice {
await startEchoingDeviceLog(); await startEchoingDeviceLog();
final LaunchResult result = await device!.startApp( final LaunchResult result = await device!.startApp(
package, applicationPackage,
mainPath: coldRunner.mainPath, mainPath: coldRunner.mainPath,
debuggingOptions: coldRunner.debuggingOptions, debuggingOptions: coldRunner.debuggingOptions,
platformArgs: platformArgs, platformArgs: platformArgs,

View File

@ -47,12 +47,13 @@ class IntegrationTestTestDevice implements TestDevice {
targetPlatform, targetPlatform,
buildInfo: debuggingOptions.buildInfo, buildInfo: debuggingOptions.buildInfo,
); );
if (_applicationPackage == null) { final ApplicationPackage? package = _applicationPackage;
if (package == null) {
throw TestDeviceException('No application found for $targetPlatform.', StackTrace.current); throw TestDeviceException('No application found for $targetPlatform.', StackTrace.current);
} }
final LaunchResult launchResult = await device.startApp( final LaunchResult launchResult = await device.startApp(
_applicationPackage, package,
mainPath: entrypointPath, mainPath: entrypointPath,
platformArgs: <String, dynamic>{}, platformArgs: <String, dynamic>{},
debuggingOptions: debuggingOptions, debuggingOptions: debuggingOptions,

View File

@ -130,7 +130,7 @@ class FlutterTesterDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage package, { ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
@ -217,7 +217,7 @@ class FlutterTesterDevice extends Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
ApplicationPackage app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
_process?.kill(); _process?.kill();
@ -236,7 +236,7 @@ class FlutterTesterDevice extends Device {
@override @override
DevFSWriter createDevFSWriter( DevFSWriter createDevFSWriter(
covariant ApplicationPackage app, ApplicationPackage? app,
String? userIdentifier, String? userIdentifier,
) { ) {
return LocalDevFSWriter( return LocalDevFSWriter(

View File

@ -118,7 +118,7 @@ abstract class ChromiumDevice extends Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
WebApplicationPackage? package, { ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,

View File

@ -49,8 +49,7 @@ class WindowsDevice extends DesktopDevice {
} }
@override @override
Future<void> buildForDevice( Future<void> buildForDevice({
covariant WindowsApp package, {
String? mainPath, String? mainPath,
required BuildInfo buildInfo, required BuildInfo buildInfo,
}) async { }) async {

View File

@ -6,7 +6,7 @@ import 'dart:async';
import 'package:file/memory.dart'; import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_device.dart'; import 'package:flutter_tools/src/android/android_device.dart';
import 'package:flutter_tools/src/android/application_package.dart'; import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/artifacts.dart'; import 'package:flutter_tools/src/artifacts.dart';
import 'package:flutter_tools/src/base/common.dart'; import 'package:flutter_tools/src/base/common.dart';
import 'package:flutter_tools/src/base/dds.dart'; import 'package:flutter_tools/src/base/dds.dart';
@ -947,7 +947,7 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
@override @override
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
AndroidApk? app, ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}) { }) {
if (onGetLogReader == null) { if (onGetLogReader == null) {

View File

@ -886,15 +886,16 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
late DeviceLogReader logReader; late DeviceLogReader logReader;
@override @override
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
covariant ApplicationPackage? app, ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}) => logReader; }) => logReader;
ApplicationPackage? startAppPackage; ApplicationPackage? startAppPackage;
late LaunchResult launchResult; late LaunchResult launchResult;
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage package, { ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
DebuggingOptions? debuggingOptions, DebuggingOptions? debuggingOptions,

View File

@ -148,7 +148,7 @@ class FakeIOSDevice extends Fake implements IOSDevice {
@override @override
Future<bool> isAppInstalled( Future<bool> isAppInstalled(
IOSApp app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) async => false; }) async => false;
@ -168,7 +168,7 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
@override @override
Future<bool> isAppInstalled( Future<bool> isAppInstalled(
AndroidApk app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) async => false; }) async => false;

View File

@ -302,7 +302,7 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
late DeviceLogReader logReader; late DeviceLogReader logReader;
@override @override
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
covariant ApplicationPackage? app, ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}) => logReader; }) => logReader;
@ -310,7 +310,7 @@ class FakeAndroidDevice extends Fake implements AndroidDevice {
late LaunchResult launchResult; late LaunchResult launchResult;
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
ApplicationPackage package, { ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
DebuggingOptions? debuggingOptions, DebuggingOptions? debuggingOptions,

View File

@ -990,7 +990,7 @@ class FakeDevice extends Fake implements Device {
@override @override
DevFSWriter? createDevFSWriter( DevFSWriter? createDevFSWriter(
covariant ApplicationPackage? app, ApplicationPackage? app,
String? userIdentifier, String? userIdentifier,
) { ) {
return null; return null;

View File

@ -137,6 +137,7 @@ void main() {
expect(await device.isLatestBuildInstalled(linuxApp), false); expect(await device.isLatestBuildInstalled(linuxApp), false);
expect(await device.isAppInstalled(linuxApp), false); expect(await device.isAppInstalled(linuxApp), false);
expect(await device.stopApp(linuxApp), false); expect(await device.stopApp(linuxApp), false);
expect(await device.stopApp(null), false);
expect(device.category, Category.mobile); expect(device.category, Category.mobile);
expect(device.supportsRuntimeMode(BuildMode.debug), true); expect(device.supportsRuntimeMode(BuildMode.debug), true);

View File

@ -357,8 +357,7 @@ class FakeDesktopDevice extends DesktopDevice {
bool isSupportedForProject(FlutterProject flutterProject) => true; bool isSupportedForProject(FlutterProject flutterProject) => true;
@override @override
Future<void> buildForDevice( Future<void> buildForDevice({
ApplicationPackage package, {
String? mainPath, String? mainPath,
BuildInfo? buildInfo, BuildInfo? buildInfo,
}) async { }) async {

View File

@ -503,13 +503,13 @@ class FakeDevice extends Fake implements Device {
@override @override
Future<DeviceLogReader> getLogReader({ Future<DeviceLogReader> getLogReader({
covariant ApplicationPackage? app, ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}) async => NoOpDeviceLogReader('test'); }) async => NoOpDeviceLogReader('test');
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
covariant ApplicationPackage package, { ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
required DebuggingOptions debuggingOptions, required DebuggingOptions debuggingOptions,
@ -526,13 +526,13 @@ class FakeDevice extends Fake implements Device {
} }
@override @override
Future<bool> stopApp(covariant ApplicationPackage app, {String? userIdentifier}) async { Future<bool> stopApp(ApplicationPackage? app, {String? userIdentifier}) async {
didStopApp = true; didStopApp = true;
return true; return true;
} }
@override @override
Future<bool> uninstallApp(covariant ApplicationPackage app, {String? userIdentifier}) async { Future<bool> uninstallApp(ApplicationPackage app, {String? userIdentifier}) async {
didUninstallApp = true; didUninstallApp = true;
return true; return true;
} }

View File

@ -607,7 +607,7 @@ class FakeDevice extends Fake implements Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
covariant ApplicationPackage? app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
return true; return true;

View File

@ -141,7 +141,7 @@ void main() {
), ),
throwsA(isA<UnimplementedError>()), throwsA(isA<UnimplementedError>()),
); );
await expectLater(() => device.buildForDevice(FakeIOSApp(), buildInfo: BuildInfo.debug), throwsA(isA<UnimplementedError>())); await expectLater(() => device.buildForDevice(buildInfo: BuildInfo.debug), throwsA(isA<UnimplementedError>()));
expect(device.executablePathForDevice(FakeIOSApp(), BuildMode.debug), null); expect(device.executablePathForDevice(FakeIOSApp(), BuildMode.debug), null);
}); });
} }

View File

@ -2649,7 +2649,7 @@ class FakeDevice extends Fake implements Device {
} }
@override @override
Future<bool> stopApp(covariant ApplicationPackage? app, {String? userIdentifier}) async { Future<bool> stopApp(ApplicationPackage? app, {String? userIdentifier}) async {
appStopped = true; appStopped = true;
return true; return true;
} }
@ -2664,7 +2664,7 @@ class FakeDevice extends Fake implements Device {
@override @override
FutureOr<DeviceLogReader> getLogReader({ FutureOr<DeviceLogReader> getLogReader({
covariant ApplicationPackage? app, ApplicationPackage? app,
bool includePastLogs = false, bool includePastLogs = false,
}) => NoOpDeviceLogReader(name); }) => NoOpDeviceLogReader(name);

View File

@ -189,7 +189,7 @@ class FakeWebDevice extends Fake implements Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
covariant ApplicationPackage? app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
return true; return true;
@ -197,7 +197,7 @@ class FakeWebDevice extends Fake implements Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
covariant ApplicationPackage? package, { ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
DebuggingOptions? debuggingOptions, DebuggingOptions? debuggingOptions,

View File

@ -1273,7 +1273,7 @@ class FakeDevice extends Fake implements Device {
@override @override
Future<LaunchResult> startApp( Future<LaunchResult> startApp(
covariant ApplicationPackage? package, { ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
DebuggingOptions? debuggingOptions, DebuggingOptions? debuggingOptions,
@ -1287,7 +1287,7 @@ class FakeDevice extends Fake implements Device {
@override @override
Future<bool> stopApp( Future<bool> stopApp(
covariant ApplicationPackage? app, { ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async { }) async {
if (count > 0) { if (count > 0) {

View File

@ -82,7 +82,7 @@ class FakeDevice extends Device {
final String name; final String name;
@override @override
Future<LaunchResult> startApp(covariant ApplicationPackage package, { Future<LaunchResult> startApp(ApplicationPackage? package, {
String? mainPath, String? mainPath,
String? route, String? route,
DebuggingOptions? debuggingOptions, DebuggingOptions? debuggingOptions,
@ -93,13 +93,13 @@ class FakeDevice extends Device {
}) async => _launchResult; }) async => _launchResult;
@override @override
Future<bool> stopApp(covariant ApplicationPackage app, { Future<bool> stopApp(ApplicationPackage? app, {
String? userIdentifier, String? userIdentifier,
}) async => true; }) async => true;
@override @override
Future<bool> uninstallApp( Future<bool> uninstallApp(
covariant ApplicationPackage app, { ApplicationPackage app, {
String? userIdentifier, String? userIdentifier,
}) async => true; }) async => true;