use adbkit
Summary: Replace the custom call to ADB with using this.device.adb`. Reviewed By: jknoxville Differential Revision: D17343234 fbshipit-source-id: c83fe295ec2c3f994e545a93aa580f44e91291fb
This commit is contained in:
committed by
Facebook Github Bot
parent
4e7cf077b8
commit
62a73fff14
@@ -1,37 +0,0 @@
|
||||
/**
|
||||
* Copyright 2018-present Facebook.
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
* @format
|
||||
*/
|
||||
|
||||
import proc from 'child_process';
|
||||
|
||||
function execADB(
|
||||
command: string,
|
||||
device: string | null,
|
||||
...args: Array<string>
|
||||
): Promise<string> {
|
||||
const deviceSpecifier = device != null && device !== '' ? `-s ${device}` : '';
|
||||
return new Promise((resolve, reject) => {
|
||||
const adb = `adb ${deviceSpecifier} ${command} ${args.join(' ')}`;
|
||||
proc.exec(adb, (error, stdout, _stderr) => {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve(stdout);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export async function reverse(
|
||||
local: number,
|
||||
remote: number,
|
||||
device?: string,
|
||||
): Promise<string> {
|
||||
return await execADB(
|
||||
`reverse tcp:${local} tcp:${remote}`,
|
||||
device != null ? device : null,
|
||||
);
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import {FlipperPlugin, AndroidDevice, styled} from 'flipper';
|
||||
import React from 'react';
|
||||
import getPort from 'get-port';
|
||||
import address from 'address';
|
||||
import {reverse} from './ADB';
|
||||
|
||||
const Container = styled('div')({
|
||||
display: 'flex',
|
||||
@@ -82,7 +81,8 @@ export default class extends FlipperPlugin<{}, any, {}> {
|
||||
this.client.call('config', {port, host});
|
||||
|
||||
if (['quest', 'go', 'pacific'].includes(device.title.toLowerCase())) {
|
||||
reverse(port, port);
|
||||
const device = await this.getDevice();
|
||||
(device as AndroidDevice).reverse([port, port]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user