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