List contents of Flipper folder on Android

Summary:
Design doc: https://docs.google.com/document/d/1HLCFl46RfqG0o1mSt8SWrwf_HMfOCRg_oENioc1rkvQ/edit#

In later diffs, we'll start fetching the actual files as well. The list of available files itself might be useful already to see what we have in our folder on the device

Reviewed By: passy

Differential Revision: D40508960

fbshipit-source-id: 96193fef3fed64d509cd3397513ae3e94438ae22
This commit is contained in:
Andrey Goncharov
2022-10-25 05:31:48 -07:00
committed by Facebook GitHub Bot
parent 2db9bccf75
commit 480a3d26f0
5 changed files with 84 additions and 9 deletions

View File

@@ -53,6 +53,7 @@ import {initializeAdbClient} from './devices/android/adbClient';
import {assertNotNull} from './comms/Utilities';
import {mkdirp} from 'fs-extra';
import {flipperDataFolder, flipperSettingsFolder} from './utils/paths';
import {DebuggableDevice} from './devices/DebuggableDevice';
const {access, copyFile, mkdir, unlink, stat, readlink, readFile, writeFile} =
promises;
@@ -419,10 +420,7 @@ export class FlipperServerImpl implements FlipperServer {
'device-clear-logs': async (serial) => this.getDevice(serial).clearLogs(),
'device-navigate': async (serial, loc) =>
this.getDevice(serial).navigateToLocation(loc),
'fetch-debug-data': async () => {
// TODO: Implement fetching client logs from all devices
return [];
},
'fetch-debug-data': () => this.fetchDebugLogs(),
'metro-command': async (serial: string, command: string) => {
const device = this.getDevice(serial);
if (!(device instanceof MetroDevice)) {
@@ -604,6 +602,17 @@ export class FlipperServerImpl implements FlipperServer {
return Array.from(this.devices.values());
}
private async fetchDebugLogs() {
const debugDataForEachDevice = await Promise.all(
[...this.devices.values()]
.filter((device) => device.info.os === 'Android')
.map((device) =>
(device as unknown as DebuggableDevice).readFlipperFolderForAllApps(),
),
);
return debugDataForEachDevice.flat();
}
public async close() {
this.server.close();
for (const device of this.devices.values()) {