archive disconnected Android devices

Summary:
Adding a `archive` method to Android devices, that returns a new ArchivedDevice with the same properties as the Android device. This method is called when an android device disconnects and the new ArchivedDevice is added to the devices list. When the device reconnects again, the archived device is removed.

Currently only logs are persisted. In following diffs we can:
- add support for iOS
- move the persisted pluginStates to the archived device as well

Reviewed By: passy

Differential Revision: D15942904

fbshipit-source-id: 07c5415994594abd630d0c4b458b76d1aac6ef02
This commit is contained in:
Daniel Büchele
2019-06-24 03:32:17 -07:00
committed by Facebook Github Bot
parent fdd75a123f
commit 74d7359cbe
5 changed files with 60 additions and 6 deletions

View File

@@ -6,7 +6,6 @@
*/
import {Component, Button, styled} from 'flipper';
import ArchivedDevice from '../devices/ArchivedDevice.js';
import {connect} from 'react-redux';
import {spawn} from 'child_process';
import {dirname} from 'path';
@@ -65,7 +64,7 @@ class DevicesButton extends Component<Props> {
let buttonLabel = 'No device selected';
let icon = 'minus-circle';
if (selectedDevice instanceof ArchivedDevice) {
if (selectedDevice?.isArchived) {
buttonLabel = `${selectedDevice?.title || 'Unknown device'} (offline)`;
icon = 'box';
} else if (selectedDevice?.deviceType === 'physical') {
@@ -117,11 +116,11 @@ class DevicesButton extends Component<Props> {
// Archived
const importedFiles = [
{
label: 'Imported Devices',
label: 'Disconnected Devices',
enabled: false,
},
...devices
.filter(device => device instanceof ArchivedDevice)
.filter(device => device.isArchived)
.map((device: BaseDevice) => ({
click: () => selectDevice(device),
checked: device === selectedDevice,
@@ -137,8 +136,10 @@ class DevicesButton extends Component<Props> {
const emulators = Array.from(androidEmulators)
.filter(
(name: string) =>
devices.findIndex((device: BaseDevice) => device.title === name) ===
-1,
devices.findIndex(
(device: BaseDevice) =>
device.title === name && !device.isArchived,
) === -1,
)
.map((name: string) => ({
label: name,