(&self, device: AndroidDevice)
| 773 | } |
| 774 | |
| 775 | fn device_value(&self, device: AndroidDevice) -> Value { |
| 776 | let id = id_for_avd(&device.avd_name); |
| 777 | let private_display = if let Some(serial) = device.serial.as_deref() { |
| 778 | let metrics = |
| 779 | self.display_metrics_for_serial(serial) |
| 780 | .unwrap_or(AndroidDisplayMetrics { |
| 781 | width: 0.0, |
| 782 | height: 0.0, |
| 783 | rotation_quarter_turns: 0, |
| 784 | corner_radii: AndroidCornerRadii::ZERO, |
| 785 | }); |
| 786 | json!({ |
| 787 | "displayReady": metrics.width > 0.0 && metrics.height > 0.0, |
| 788 | "displayStatus": "Ready", |
| 789 | "displayWidth": metrics.width, |
| 790 | "displayHeight": metrics.height, |
| 791 | "frameSequence": 0, |
| 792 | "rotationQuarterTurns": metrics.rotation_quarter_turns, |
| 793 | }) |
| 794 | } else { |
| 795 | json!({ |
| 796 | "displayReady": false, |
| 797 | "displayStatus": "Boot required", |
| 798 | "displayWidth": 0, |
| 799 | "displayHeight": 0, |
| 800 | "frameSequence": 0, |
| 801 | "rotationQuarterTurns": 0, |
| 802 | }) |
| 803 | }; |
| 804 | json!({ |
| 805 | "udid": id, |
| 806 | "id": id, |
| 807 | "platform": "android-emulator", |
| 808 | "name": device.avd_name, |
| 809 | "state": if device.is_booted { "Booted" } else { "Shutdown" }, |
| 810 | "isBooted": device.is_booted, |
| 811 | "isAvailable": true, |
| 812 | "lastBootedAt": Value::Null, |
| 813 | "dataPath": self.avd_dir(&device.avd_name), |
| 814 | "logPath": Value::Null, |
| 815 | "deviceTypeIdentifier": "android-emulator", |
| 816 | "deviceTypeName": "Android Emulator", |
| 817 | "runtimeIdentifier": "android", |
| 818 | "runtimeName": "Android", |
| 819 | "android": { |
| 820 | "avdName": device.avd_name, |
| 821 | "serial": device.serial, |
| 822 | "consolePort": device.console_port, |
| 823 | }, |
| 824 | "privateDisplay": private_display, |
| 825 | }) |
| 826 | } |
| 827 | |
| 828 | fn serial_for_id(&self, id: &str) -> Result<String, AppError> { |
| 829 | self.resolve_serial(&avd_from_id(id)?) |
no test coverage detected