Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
format
  • Loading branch information
Chris Yang committed Feb 23, 2021
commit c389a6ab9d8d26c1b380cd39df9a83095f376cc2
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ class MethodChannelDeviceInfo extends DeviceInfoPlatform {

// Method channel for Android devices
Future<AndroidDeviceInfo> androidInfo() async {
return AndroidDeviceInfo.fromMap(
(await channel.invokeMapMethod<String, dynamic>('getAndroidDeviceInfo')) ?? <String, dynamic>{}
);
return AndroidDeviceInfo.fromMap((await channel
.invokeMapMethod<String, dynamic>('getAndroidDeviceInfo')) ??
<String, dynamic>{});
}

// Method channel for iOS devices
Future<IosDeviceInfo> iosInfo() async {
return IosDeviceInfo.fromMap(
(await channel.invokeMapMethod<String, dynamic>('getIosDeviceInfo')) ?? <String, dynamic>{}
);
(await channel.invokeMapMethod<String, dynamic>('getIosDeviceInfo')) ??
<String, dynamic>{});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ class AndroidDeviceInfo {
/// Deserializes from the message received from [_kChannel].
static AndroidDeviceInfo fromMap(Map<String, dynamic> map) {
return AndroidDeviceInfo(
version:
AndroidBuildVersion._fromMap(map['version'] != null ? map['version'].cast<String, dynamic>() : <String, dynamic>{}),
version: AndroidBuildVersion._fromMap(map['version'] != null
? map['version'].cast<String, dynamic>()
: <String, dynamic>{}),
board: map['board'] ?? '',
bootloader: map['bootloader'] ?? '',
brand: map['brand'] ?? '',
Expand Down Expand Up @@ -144,7 +145,8 @@ class AndroidDeviceInfo {
return <String>[];
}
assert(message is List<dynamic>);
final List<dynamic> list = List<dynamic>.from(message)..removeWhere((value) => value == null);
final List<dynamic> list = List<dynamic>.from(message)
..removeWhere((value) => value == null);
print(list);
return List<String>.from(list);
}
Expand Down Expand Up @@ -200,7 +202,7 @@ class AndroidBuildVersion {
codename: map['codename'] ?? '',
incremental: map['incremental'] ?? '',
release: map['release'] ?? '',
sdkInt: map['sdkInt'] ?? -1,
sdkInt: map['sdkInt'] ?? -1,
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,12 @@ class IosDeviceInfo {
model: map['model'] ?? '',
localizedModel: map['localizedModel'] ?? '',
identifierForVendor: map['identifierForVendor'] ?? '',
isPhysicalDevice: map['isPhysicalDevice'] != null ? map['isPhysicalDevice'] == 'true' : false,
utsname: IosUtsname._fromMap(map['utsname'] != null ? map['utsname'].cast<String, dynamic>() : <String, dynamic>{}),
isPhysicalDevice: map['isPhysicalDevice'] != null
? map['isPhysicalDevice'] == 'true'
: false,
utsname: IosUtsname._fromMap(map['utsname'] != null
? map['utsname'].cast<String, dynamic>()
: <String, dynamic>{}),
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@ void main() {
});
});


group("$MethodChannelDeviceInfo handles null value in the map returned from method channel", () {
group(
"$MethodChannelDeviceInfo handles null value in the map returned from method channel",
() {
MethodChannelDeviceInfo methodChannelDeviceInfo;

setUp(() async {
Expand All @@ -177,8 +178,7 @@ void main() {
"brand": null,
"device": null,
"display": null,
"fingerprint":
null,
"fingerprint": null,
"hardware": null,
"host": null,
"id": null,
Expand Down Expand Up @@ -250,8 +250,7 @@ void main() {
expect(result.systemVersion, '');
expect(result.model, '');
expect(result.localizedModel, '');
expect(
result.identifierForVendor, '');
expect(result.identifierForVendor, '');
expect(result.isPhysicalDevice, false);
expect(result.utsname.sysname, '');
expect(result.utsname.nodename, '');
Expand Down Expand Up @@ -319,8 +318,7 @@ void main() {
expect(result.systemVersion, '');
expect(result.model, '');
expect(result.localizedModel, '');
expect(
result.identifierForVendor, '');
expect(result.identifierForVendor, '');
expect(result.isPhysicalDevice, false);
expect(result.utsname.sysname, '');
expect(result.utsname.nodename, '');
Expand All @@ -336,22 +334,14 @@ void main() {
setUp(() async {
methodChannelDeviceInfo = MethodChannelDeviceInfo();

methodChannelDeviceInfo.channel
methodChannelDeviceInfo.channel
.setMockMethodCallHandler((MethodCall methodCall) async {
switch (methodCall.method) {
case 'getAndroidDeviceInfo':
return ({
"supported32BitAbis": <String>[
"x86", null
],
"supported64BitAbis": <String>[
"x86_64", null
],
"supportedAbis": <String>[
"x86_64",
"x86",
null
],
"supported32BitAbis": <String>["x86", null],
"supported64BitAbis": <String>["x86_64", null],
"supportedAbis": <String>["x86_64", "x86", null],
"systemFeatures": <String>[
"android.hardware.sensor.proximity",
"android.software.adoptable_storage",
Expand All @@ -374,12 +364,14 @@ void main() {
expect(result.supported32BitAbis, <String>['x86']);
expect(result.supported64BitAbis, <String>['x86_64']);
expect(result.supportedAbis, <String>['x86_64', 'x86']);
expect(result.systemFeatures, <String>[ "android.hardware.sensor.proximity",
"android.software.adoptable_storage",
"android.hardware.sensor.accelerometer",
"android.hardware.faketouch",
"android.software.backup",
"android.hardware.touchscreen"]);
expect(result.systemFeatures, <String>[
"android.hardware.sensor.proximity",
"android.software.adoptable_storage",
"android.hardware.sensor.accelerometer",
"android.hardware.faketouch",
"android.software.backup",
"android.hardware.touchscreen"
]);
});
});
}