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:
committed by
Facebook Github Bot
parent
fdd75a123f
commit
74d7359cbe
@@ -11,6 +11,7 @@ import {Priority} from 'adbkit-logcat-fb';
|
||||
import child_process from 'child_process';
|
||||
import child_process_promise from 'child-process-es6-promise';
|
||||
import BaseDevice from './BaseDevice.js';
|
||||
import ArchivedDevice from './ArchivedDevice.js';
|
||||
|
||||
type ADBClient = any;
|
||||
|
||||
@@ -85,4 +86,14 @@ export default class AndroidDevice extends BaseDevice {
|
||||
clearLogs(): Promise<void> {
|
||||
return child_process_promise.spawn('adb', ['logcat', '-c']);
|
||||
}
|
||||
|
||||
archive(): ArchivedDevice {
|
||||
return new ArchivedDevice(
|
||||
this.serial,
|
||||
this.deviceType,
|
||||
this.title,
|
||||
this.os,
|
||||
[...this.logEntries],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ export default class ArchivedDevice extends BaseDevice {
|
||||
|
||||
logs: Array<DeviceLogEntry>;
|
||||
|
||||
isArchived = true;
|
||||
|
||||
getLogs() {
|
||||
return this.logs;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import type stream from 'stream';
|
||||
import type ArchivedDevice from './ArchivedDevice';
|
||||
|
||||
export type LogLevel =
|
||||
| 'unknown'
|
||||
@@ -74,6 +75,7 @@ export default class BaseDevice {
|
||||
|
||||
logListeners: Map<Symbol, DeviceLogListener> = new Map();
|
||||
logEntries: Array<DeviceLogEntry> = [];
|
||||
isArchived: boolean = false;
|
||||
|
||||
supportsOS(os: OS) {
|
||||
return os.toLowerCase() === this.os.toLowerCase();
|
||||
@@ -135,4 +137,8 @@ export default class BaseDevice {
|
||||
spawnShell(): ?DeviceShell {
|
||||
throw new Error('unimplemented');
|
||||
}
|
||||
|
||||
archive(): ?ArchivedDevice {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user