Restore adb executeShell [5/n]
Summary: Expose executeShell explicitly through the device interface Reviewed By: jameslawson Differential Revision: D31055959 fbshipit-source-id: b14395d0783ede265c6ae39c397ea93a85a78336
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4463e7ede2
commit
8cf182cc26
@@ -42,6 +42,7 @@ export interface Device {
|
||||
readonly serial: string;
|
||||
readonly deviceType: DeviceType;
|
||||
onLogEntry(cb: DeviceLogListener): () => void;
|
||||
executeShell(command: string): Promise<string>;
|
||||
}
|
||||
|
||||
export type DevicePluginPredicate = (device: Device) => boolean;
|
||||
@@ -69,6 +70,7 @@ export interface RealFlipperDevice {
|
||||
deviceType: DeviceType;
|
||||
addLogListener(callback: DeviceLogListener): Symbol;
|
||||
removeLogListener(id: Symbol): void;
|
||||
executeShell(command: string): Promise<string>;
|
||||
}
|
||||
|
||||
export class SandyDevicePluginInstance extends BasePluginInstance {
|
||||
|
||||
@@ -216,6 +216,9 @@ export abstract class BasePluginInstance {
|
||||
realDevice.removeLogListener(handle);
|
||||
};
|
||||
},
|
||||
executeShell(command: string): Promise<string> {
|
||||
return realDevice.executeShell(command);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -506,6 +506,7 @@ function createMockDevice(options?: StartPluginOptions): RealFlipperDevice & {
|
||||
addLogEntry(entry: DeviceLogEntry) {
|
||||
logListeners.forEach((f) => f?.(entry));
|
||||
},
|
||||
executeShell: jest.fn(),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -74,18 +74,7 @@ function formatFrequency(freq: number) {
|
||||
export function devicePlugin(client: PluginClient<{}, {}>) {
|
||||
const device = client.device;
|
||||
|
||||
const executeShell = async (command: string) => {
|
||||
// TODO: fix
|
||||
return new Promise<string>((resolve, reject) => {
|
||||
(device.realDevice as any).adb
|
||||
.shell(device.serial, command)
|
||||
.then(adb.util.readAll)
|
||||
.then(function (output: {toString: () => {trim: () => string}}) {
|
||||
resolve(output.toString().trim());
|
||||
})
|
||||
.catch((e: unknown) => reject(e));
|
||||
});
|
||||
};
|
||||
const executeShell = async (command: string) => device.executeShell(command);
|
||||
|
||||
let intervalID: NodeJS.Timer | null = null;
|
||||
const cpuState = createState<CPUState>({
|
||||
|
||||
Reference in New Issue
Block a user