Skip to content

Commit c5edd33

Browse files
authored
Rename id to serial (#338)
1 parent 5a6d2e6 commit c5edd33

File tree

3 files changed

+27
-24
lines changed

3 files changed

+27
-24
lines changed

tools/lib/src/device.dart

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ class Device {
4747
tizenSdk: tizenSdk,
4848
processRunner: processRunner,
4949
);
50-
device._id = device._findId();
51-
if (device._id == null) {
52-
throw Exception('$name($profile)\'s id is null. '
50+
device._serial = device._findSerial();
51+
if (device._serial == null) {
52+
throw Exception('$name($profile)\'s serial is null. '
5353
'Physical device references must be connected to host PC.');
5454
}
5555
return device;
@@ -80,30 +80,33 @@ class Device {
8080

8181
final TizenSdk _tizenSdk;
8282

83-
String? _id;
83+
String? _serial;
8484

8585
final ProcessRunner _processRunner;
8686

8787
/// The unqiue identifier assigned to a connected device.
88-
String? get id => _id;
88+
///
89+
/// Physical devices have baked in serial numbers while emulators
90+
/// are assigned with a port number when they're launched.
91+
String? get serial => _serial;
8992

9093
/// Whether this device is an emulator.
9194
bool get isEmulator => false;
9295

9396
/// Whether this device is connected to host PC.
9497
bool get isConnected {
95-
_id = _findId();
96-
return _id != null;
98+
_serial = _findSerial();
99+
return _serial != null;
97100
}
98101

99102
static final RegExp _logPattern =
100103
RegExp(r'\d\d:\d\d\s+([(\+\d+\s+)|(~\d+\s+)|(\-\d+\s+)]+):\s+(.*)');
101104

102-
String? _findId() {
105+
String? _findSerial() {
103106
final List<SdbDeviceInfo> deviceInfos = _tizenSdk.sdbDevices();
104107
for (final SdbDeviceInfo deviceInfo in deviceInfos) {
105108
if (deviceInfo.name == name) {
106-
return deviceInfo.id;
109+
return deviceInfo.serial;
107110
}
108111
}
109112
return null;
@@ -133,7 +136,7 @@ class Device {
133136

134137
final io.Process process = await _processRunner.start(
135138
'flutter-tizen',
136-
<String>['-d', id!, 'test', 'integration_test'],
139+
<String>['-d', serial!, 'test', 'integration_test'],
137140
workingDirectory: workingDir,
138141
);
139142

@@ -207,7 +210,7 @@ class EmulatorDevice extends Device {
207210
tizenSdk: tizenSdk,
208211
processRunner: processRunner,
209212
);
210-
emulatorDevice._id = emulatorDevice._findId();
213+
emulatorDevice._serial = emulatorDevice._findSerial();
211214
emulatorDevice._pid = findEmulatorPid(name);
212215
return emulatorDevice;
213216
}
@@ -228,9 +231,9 @@ class EmulatorDevice extends Device {
228231

229232
@override
230233
bool get isConnected {
231-
_id = _findId();
234+
_serial = _findSerial();
232235
_pid = findEmulatorPid(name);
233-
return _id != null && _pid != null;
236+
return _serial != null && _pid != null;
234237
}
235238

236239
@override
@@ -309,7 +312,7 @@ class EmulatorDevice extends Device {
309312
}
310313
return false;
311314
});
312-
_id = _findId();
315+
_serial = _findSerial();
313316
}
314317

315318
/// Closes this emulator.
@@ -335,7 +338,7 @@ class EmulatorDevice extends Device {
335338
return true;
336339
});
337340
_pid = null;
338-
_id = null;
341+
_serial = null;
339342
}
340343

341344
Future<void> _poll(

tools/lib/src/integration_test_command.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,14 +235,14 @@ class IntegrationTestCommand extends PackageLoopingCommand {
235235
final List<SdbDeviceInfo> deviceInfos = _tizenSdk.sdbDevices();
236236
for (final SdbDeviceInfo deviceInfo in deviceInfos) {
237237
final Map<String, String> capability =
238-
_tizenSdk.sdbCapability(deviceInfo.id);
238+
_tizenSdk.sdbCapability(deviceInfo.serial);
239239
final String? deviceType = capability['profile_name'];
240240
final String? version = capability['platform_version'];
241241
final String? cpuArch = capability['cpu_arch'];
242242
if (deviceType == null || version == null || cpuArch == null) {
243243
throw Exception(
244244
'Cannot extract profile, Tizen version, or cpu arch from '
245-
'target ${deviceInfo.id}.\n'
245+
'target ${deviceInfo.serial}.\n'
246246
'profile: $deviceType\n'
247247
'Tizen version: $version\n'
248248
'cpu arch: $cpuArch');

tools/lib/src/tizen_sdk.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ import 'package:pub_semver/pub_semver.dart';
1313

1414
import 'process_runner_apis.dart';
1515

16-
/// A data type that holds information such as id and status of
16+
/// A data type that holds information such as serial and status of
1717
/// a connected device.
1818
class SdbDeviceInfo {
1919
/// Creates a [SdbDeviceInfo] instance.
2020
const SdbDeviceInfo({
21-
required this.id,
21+
required this.serial,
2222
required this.status,
2323
required this.name,
2424
});
2525

2626
/// The unique string that identifies a running device.
27-
final String id;
27+
final String serial;
2828

2929
/// The current connection state of the device.
3030
///
@@ -228,7 +228,7 @@ class TizenSdk {
228228
}
229229

230230
deviceInfos.add(SdbDeviceInfo(
231-
id: tokens[0],
231+
serial: tokens[0],
232232
status: tokens[1],
233233
name: tokens[2],
234234
));
@@ -238,11 +238,11 @@ class TizenSdk {
238238
}
239239

240240
/// Returns the result of running sdb capability as a map of key-value pairs.
241-
Map<String, String> sdbCapability(String id) {
241+
Map<String, String> sdbCapability(String serial) {
242242
final io.ProcessResult result =
243-
_processRunner.runSync(sdb.path, <String>['-s', id, 'capability']);
243+
_processRunner.runSync(sdb.path, <String>['-s', serial, 'capability']);
244244
if (result.exitCode != 0) {
245-
print('Error: running command `sdb -s $id capability` failed.');
245+
print('Error: running command `sdb -s $serial capability` failed.');
246246
throw ToolExit(result.exitCode);
247247
}
248248

0 commit comments

Comments
 (0)