Allow to start only one instance of log listener and crash watcher

Summary:
Changelog: Allow only a single crash watcher and a single log listener per device. Start log listener and crash watcher for every device upon connection. Remove commands to start/stop them externally.

Monitored CPU load for a physical Android device with the log listener on and off. Did not notice any real difference.

Resolved crashing adbkit-logcat by forcing the usage of 2.0.1. A proper fix would be to unify babel transforms for browser flipper and electron flipper, but we might re-think how we distribute flipper in the next half, so a simple hot fix might be a better use of time and resources.

Reviewed By: mweststrate

Differential Revision: D33132506

fbshipit-source-id: 39d422682a10a64830ac516e30f43f32f416819d
This commit is contained in:
Andrey Goncharov
2021-12-20 11:37:25 -08:00
committed by Facebook GitHub Bot
parent 731749b41f
commit debf872806
19 changed files with 838 additions and 424 deletions

View File

@@ -8,6 +8,7 @@
*/
import {DeviceDescription, DeviceLogEntry} from 'flipper-common';
import {DeviceListener, NoopListener} from '../utils/DeviceListener';
import {FlipperServerImpl} from '../FlipperServerImpl';
export abstract class ServerDevice {
@@ -17,6 +18,11 @@ export abstract class ServerDevice {
protected stopCrashWatcherCb?: () => void;
readonly logListener: DeviceListener = new NoopListener(() => this.connected);
readonly crashWatcher: DeviceListener = new NoopListener(
() => this.connected,
);
constructor(flipperServer: FlipperServerImpl, info: DeviceDescription) {
this.flipperServer = flipperServer;
this.info = info;
@@ -38,28 +44,8 @@ export abstract class ServerDevice {
*/
disconnect(): void {
this.connected = false;
}
startLogging() {
// to be subclassed
}
stopLogging() {
// to be subclassed
}
startCrashWatcher() {
this.stopCrashWatcherCb = this.startCrashWatcherImpl?.();
}
protected startCrashWatcherImpl(): () => void {
// to be subclassed
return () => {};
}
stopCrashWatcher() {
this.stopCrashWatcherCb?.();
this.stopCrashWatcherCb = undefined;
this.logListener.stop();
this.crashWatcher.stop();
}
async screenshotAvailable(): Promise<boolean> {