Commit 34ed3d2d authored by Todd Volkert's avatar Todd Volkert Committed by GitHub

Pay off some technical debt. (#8710)

* Rename `Device.platform` to `Device.targetPlatform` to avoid
  collision with the exported variable from `platform.dart`
parent 83d411f9
...@@ -89,7 +89,7 @@ class AndroidDevice extends Device { ...@@ -89,7 +89,7 @@ class AndroidDevice extends Device {
} }
@override @override
TargetPlatform get platform { TargetPlatform get targetPlatform {
if (_platform == null) { if (_platform == null) {
// http://developer.android.com/ndk/guides/abis.html (x86, armeabi-v7a, ...) // http://developer.android.com/ndk/guides/abis.html (x86, armeabi-v7a, ...)
switch (_getProperty('ro.product.cpu.abi')) { switch (_getProperty('ro.product.cpu.abi')) {
...@@ -278,14 +278,14 @@ class AndroidDevice extends Device { ...@@ -278,14 +278,14 @@ class AndroidDevice extends Device {
if (!_checkForSupportedAdbVersion() || !_checkForSupportedAndroidVersion()) if (!_checkForSupportedAdbVersion() || !_checkForSupportedAndroidVersion())
return new LaunchResult.failed(); return new LaunchResult.failed();
if (platform != TargetPlatform.android_arm && mode != BuildMode.debug) { if (targetPlatform != TargetPlatform.android_arm && mode != BuildMode.debug) {
printError('Profile and release builds are only supported on ARM targets.'); printError('Profile and release builds are only supported on ARM targets.');
return new LaunchResult.failed(); return new LaunchResult.failed();
} }
if (!prebuiltApplication) { if (!prebuiltApplication) {
printTrace('Building APK'); printTrace('Building APK');
await buildApk(platform, await buildApk(targetPlatform,
target: mainPath, target: mainPath,
buildMode: debuggingOptions.buildMode, buildMode: debuggingOptions.buildMode,
kernelContent: kernelContent, kernelContent: kernelContent,
......
...@@ -647,7 +647,7 @@ Map<String, dynamic> _deviceToMap(Device device) { ...@@ -647,7 +647,7 @@ Map<String, dynamic> _deviceToMap(Device device) {
return <String, dynamic>{ return <String, dynamic>{
'id': device.id, 'id': device.id,
'name': device.name, 'name': device.name,
'platform': getNameForTargetPlatform(device.platform), 'platform': getNameForTargetPlatform(device.targetPlatform),
'emulator': device.isLocalEmulator 'emulator': device.isLocalEmulator
}; };
} }
......
...@@ -262,7 +262,7 @@ Future<LaunchResult> _startApp(DriveCommand command) async { ...@@ -262,7 +262,7 @@ Future<LaunchResult> _startApp(DriveCommand command) async {
printTrace('Installing application package.'); printTrace('Installing application package.');
final ApplicationPackage package = command.applicationPackages final ApplicationPackage package = command.applicationPackages
.getPackageForPlatform(command.device.platform); .getPackageForPlatform(command.device.targetPlatform);
if (command.device.isAppInstalled(package)) if (command.device.isAppInstalled(package))
command.device.uninstallApp(package); command.device.uninstallApp(package);
command.device.installApp(package); command.device.installApp(package);
...@@ -335,7 +335,7 @@ void restoreAppStopper() { ...@@ -335,7 +335,7 @@ void restoreAppStopper() {
Future<bool> _stopApp(DriveCommand command) async { Future<bool> _stopApp(DriveCommand command) async {
printTrace('Stopping application.'); printTrace('Stopping application.');
final ApplicationPackage package = command.applicationPackages.getPackageForPlatform(command.device.platform); final ApplicationPackage package = command.applicationPackages.getPackageForPlatform(command.device.targetPlatform);
final bool stopped = await command.device.stopApp(package); final bool stopped = await command.device.stopApp(package);
await command._deviceLogSubscription?.cancel(); await command._deviceLogSubscription?.cancel();
return stopped; return stopped;
......
...@@ -31,7 +31,7 @@ class InstallCommand extends FlutterCommand { ...@@ -31,7 +31,7 @@ class InstallCommand extends FlutterCommand {
@override @override
Future<Null> runCommand() async { Future<Null> runCommand() async {
final ApplicationPackage package = applicationPackages.getPackageForPlatform(device.platform); final ApplicationPackage package = applicationPackages.getPackageForPlatform(device.targetPlatform);
Cache.releaseLockEarly(); Cache.releaseLockEarly();
......
...@@ -151,7 +151,7 @@ class RunCommand extends RunCommandBase { ...@@ -151,7 +151,7 @@ class RunCommand extends RunCommandBase {
return command; return command;
// Return 'run/ios'. // Return 'run/ios'.
return '$command/${getNameForTargetPlatform(device.platform)}'; return '$command/${getNameForTargetPlatform(device.targetPlatform)}';
} }
@override @override
......
...@@ -31,9 +31,9 @@ class StopCommand extends FlutterCommand { ...@@ -31,9 +31,9 @@ class StopCommand extends FlutterCommand {
@override @override
Future<Null> runCommand() async { Future<Null> runCommand() async {
final ApplicationPackage app = applicationPackages.getPackageForPlatform(device.platform); final ApplicationPackage app = applicationPackages.getPackageForPlatform(device.targetPlatform);
if (app == null) { if (app == null) {
final String platformName = getNameForTargetPlatform(device.platform); final String platformName = getNameForTargetPlatform(device.targetPlatform);
throwToolExit('No Flutter application for $platformName found in the current directory.'); throwToolExit('No Flutter application for $platformName found in the current directory.');
} }
printStatus('Stopping apps on ${device.name}.'); printStatus('Stopping apps on ${device.name}.');
......
...@@ -167,9 +167,7 @@ abstract class Device { ...@@ -167,9 +167,7 @@ abstract class Device {
// supported by Flutter, and, if not, why. // supported by Flutter, and, if not, why.
String supportMessage() => isSupported() ? "Supported" : "Unsupported"; String supportMessage() => isSupported() ? "Supported" : "Unsupported";
// TODO(tvolkert): Rename to `targetPlatform`, and remove the "as p" TargetPlatform get targetPlatform;
// aliases on the `platform.dart` imports where applicable.
TargetPlatform get platform;
String get sdkNameAndVersion; String get sdkNameAndVersion;
...@@ -254,13 +252,13 @@ abstract class Device { ...@@ -254,13 +252,13 @@ abstract class Device {
for (Device device in devices) { for (Device device in devices) {
String supportIndicator = device.isSupported() ? '' : ' (unsupported)'; String supportIndicator = device.isSupported() ? '' : ' (unsupported)';
if (device.isLocalEmulator) { if (device.isLocalEmulator) {
final String type = device.platform == TargetPlatform.ios ? 'simulator' : 'emulator'; final String type = device.targetPlatform == TargetPlatform.ios ? 'simulator' : 'emulator';
supportIndicator += ' ($type)'; supportIndicator += ' ($type)';
} }
table.add(<String>[ table.add(<String>[
device.name, device.name,
device.id, device.id,
'${getNameForTargetPlatform(device.platform)}', '${getNameForTargetPlatform(device.targetPlatform)}',
'${device.sdkNameAndVersion}$supportIndicator', '${device.sdkNameAndVersion}$supportIndicator',
]); ]);
} }
......
...@@ -9,7 +9,7 @@ import '../application_package.dart'; ...@@ -9,7 +9,7 @@ import '../application_package.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/os.dart'; import '../base/os.dart';
import '../base/platform.dart' as p; import '../base/platform.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../build_info.dart'; import '../build_info.dart';
...@@ -31,7 +31,7 @@ class IOSDevices extends PollingDeviceDiscovery { ...@@ -31,7 +31,7 @@ class IOSDevices extends PollingDeviceDiscovery {
IOSDevices() : super('IOSDevices'); IOSDevices() : super('IOSDevices');
@override @override
bool get supportsPlatform => p.platform.isMacOS; bool get supportsPlatform => platform.isMacOS;
@override @override
List<Device> pollingGetDevices() => IOSDevice.getAttachedDevices(); List<Device> pollingGetDevices() => IOSDevice.getAttachedDevices();
...@@ -129,7 +129,7 @@ class IOSDevice extends Device { ...@@ -129,7 +129,7 @@ class IOSDevice extends Device {
try { try {
command = runCheckedSync(<String>['which', command]).trim(); command = runCheckedSync(<String>['which', command]).trim();
} catch (e) { } catch (e) {
if (p.platform.isMacOS) { if (platform.isMacOS) {
printError('$command not found. $macInstructions'); printError('$command not found. $macInstructions');
} else { } else {
printError('Cannot control iOS devices or simulators. $command is not available on your platform.'); printError('Cannot control iOS devices or simulators. $command is not available on your platform.');
...@@ -323,7 +323,7 @@ class IOSDevice extends Device { ...@@ -323,7 +323,7 @@ class IOSDevice extends Device {
} }
Future<bool> pushFile(ApplicationPackage app, String localFile, String targetFile) async { Future<bool> pushFile(ApplicationPackage app, String localFile, String targetFile) async {
if (p.platform.isMacOS) { if (platform.isMacOS) {
runSync(<String>[ runSync(<String>[
pusherPath, pusherPath,
'-t', '-t',
...@@ -342,7 +342,7 @@ class IOSDevice extends Device { ...@@ -342,7 +342,7 @@ class IOSDevice extends Device {
} }
@override @override
TargetPlatform get platform => TargetPlatform.ios; TargetPlatform get targetPlatform => TargetPlatform.ios;
@override @override
String get sdkNameAndVersion => 'iOS $_sdkVersion ($_buildVersion)'; String get sdkNameAndVersion => 'iOS $_sdkVersion ($_buildVersion)';
......
...@@ -11,7 +11,7 @@ import '../base/common.dart'; ...@@ -11,7 +11,7 @@ import '../base/common.dart';
import '../base/context.dart'; import '../base/context.dart';
import '../base/file_system.dart'; import '../base/file_system.dart';
import '../base/io.dart'; import '../base/io.dart';
import '../base/platform.dart' as p; import '../base/platform.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../base/process_manager.dart'; import '../base/process_manager.dart';
import '../build_info.dart'; import '../build_info.dart';
...@@ -31,7 +31,7 @@ class IOSSimulators extends PollingDeviceDiscovery { ...@@ -31,7 +31,7 @@ class IOSSimulators extends PollingDeviceDiscovery {
IOSSimulators() : super('IOSSimulators'); IOSSimulators() : super('IOSSimulators');
@override @override
bool get supportsPlatform => p.platform.isMacOS; bool get supportsPlatform => platform.isMacOS;
@override @override
List<Device> pollingGetDevices() => IOSSimulatorUtils.instance.getAttachedDevices(); List<Device> pollingGetDevices() => IOSSimulatorUtils.instance.getAttachedDevices();
...@@ -366,7 +366,7 @@ class IOSSimulator extends Device { ...@@ -366,7 +366,7 @@ class IOSSimulator extends Device {
@override @override
bool isSupported() { bool isSupported() {
if (!p.platform.isMacOS) { if (!platform.isMacOS) {
_supportMessage = 'iOS devices require a Mac host machine.'; _supportMessage = 'iOS devices require a Mac host machine.';
return false; return false;
} }
...@@ -541,7 +541,7 @@ class IOSSimulator extends Device { ...@@ -541,7 +541,7 @@ class IOSSimulator extends Device {
Future<bool> pushFile( Future<bool> pushFile(
ApplicationPackage app, String localFile, String targetFile) async { ApplicationPackage app, String localFile, String targetFile) async {
if (p.platform.isMacOS) { if (platform.isMacOS) {
final String simulatorHomeDirectory = _getSimulatorAppHomeDirectory(app); final String simulatorHomeDirectory = _getSimulatorAppHomeDirectory(app);
runCheckedSync(<String>['cp', localFile, fs.path.join(simulatorHomeDirectory, targetFile)]); runCheckedSync(<String>['cp', localFile, fs.path.join(simulatorHomeDirectory, targetFile)]);
return true; return true;
...@@ -554,7 +554,7 @@ class IOSSimulator extends Device { ...@@ -554,7 +554,7 @@ class IOSSimulator extends Device {
} }
@override @override
TargetPlatform get platform => TargetPlatform.ios; TargetPlatform get targetPlatform => TargetPlatform.ios;
@override @override
String get sdkNameAndVersion => category; String get sdkNameAndVersion => category;
......
...@@ -79,11 +79,11 @@ class ColdRunner extends ResidentRunner { ...@@ -79,11 +79,11 @@ class ColdRunner extends ResidentRunner {
} }
} }
package = getApplicationPackageForPlatform(device.platform, applicationBinary: applicationBinary); package = getApplicationPackageForPlatform(device.targetPlatform, applicationBinary: applicationBinary);
if (package == null) { if (package == null) {
String message = 'No application found for ${device.platform}.'; String message = 'No application found for ${device.targetPlatform}.';
final String hint = getMissingPackageHintForPlatform(device.platform); final String hint = getMissingPackageHintForPlatform(device.targetPlatform);
if (hint != null) if (hint != null)
message += '\n$hint'; message += '\n$hint';
printError(message); printError(message);
......
...@@ -124,11 +124,11 @@ class HotRunner extends ResidentRunner { ...@@ -124,11 +124,11 @@ class HotRunner extends ResidentRunner {
return 1; return 1;
} }
package = getApplicationPackageForPlatform(device.platform, applicationBinary: applicationBinary); package = getApplicationPackageForPlatform(device.targetPlatform, applicationBinary: applicationBinary);
if (package == null) { if (package == null) {
String message = 'No application found for ${device.platform}.'; String message = 'No application found for ${device.targetPlatform}.';
final String hint = getMissingPackageHintForPlatform(device.platform); final String hint = getMissingPackageHintForPlatform(device.targetPlatform);
if (hint != null) if (hint != null)
message += '\n$hint'; message += '\n$hint';
printError(message); printError(message);
......
...@@ -176,7 +176,7 @@ abstract class FlutterCommand extends Command<Null> { ...@@ -176,7 +176,7 @@ abstract class FlutterCommand extends Command<Null> {
devices = devices.where((Device device) => device.isSupported()).toList(); devices = devices.where((Device device) => device.isSupported()).toList();
if (androidOnly) if (androidOnly)
devices = devices.where((Device device) => device.platform == TargetPlatform.android_arm).toList(); devices = devices.where((Device device) => device.targetPlatform == TargetPlatform.android_arm).toList();
if (devices.isEmpty) { if (devices.isEmpty) {
printStatus('No supported devices connected.'); printStatus('No supported devices connected.');
......
...@@ -31,7 +31,7 @@ class MockApplicationPackageStore extends ApplicationPackageStore { ...@@ -31,7 +31,7 @@ class MockApplicationPackageStore extends ApplicationPackageStore {
class MockAndroidDevice extends Mock implements AndroidDevice { class MockAndroidDevice extends Mock implements AndroidDevice {
@override @override
TargetPlatform get platform => TargetPlatform.android_arm; TargetPlatform get targetPlatform => TargetPlatform.android_arm;
@override @override
bool isSupported() => true; bool isSupported() => true;
...@@ -39,7 +39,7 @@ class MockAndroidDevice extends Mock implements AndroidDevice { ...@@ -39,7 +39,7 @@ class MockAndroidDevice extends Mock implements AndroidDevice {
class MockIOSDevice extends Mock implements IOSDevice { class MockIOSDevice extends Mock implements IOSDevice {
@override @override
TargetPlatform get platform => TargetPlatform.ios; TargetPlatform get targetPlatform => TargetPlatform.ios;
@override @override
bool isSupported() => true; bool isSupported() => true;
...@@ -47,7 +47,7 @@ class MockIOSDevice extends Mock implements IOSDevice { ...@@ -47,7 +47,7 @@ class MockIOSDevice extends Mock implements IOSDevice {
class MockIOSSimulator extends Mock implements IOSSimulator { class MockIOSSimulator extends Mock implements IOSSimulator {
@override @override
TargetPlatform get platform => TargetPlatform.ios; TargetPlatform get targetPlatform => TargetPlatform.ios;
@override @override
bool isSupported() => true; bool isSupported() => true;
......
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