From 62a73fff14693d10e25786aaa899c454e9d34d2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Fri, 13 Sep 2019 05:25:36 -0700 Subject: [PATCH] use adbkit Summary: Replace the custom call to ADB with using this.device.adb`. Reviewed By: jknoxville Differential Revision: D17343234 fbshipit-source-id: c83fe295ec2c3f994e545a93aa580f44e91291fb --- src/plugins/reactdevtools/ADB.tsx | 37 ----------------------------- src/plugins/reactdevtools/index.tsx | 4 ++-- 2 files changed, 2 insertions(+), 39 deletions(-) delete mode 100644 src/plugins/reactdevtools/ADB.tsx diff --git a/src/plugins/reactdevtools/ADB.tsx b/src/plugins/reactdevtools/ADB.tsx deleted file mode 100644 index b2bbbab74..000000000 --- a/src/plugins/reactdevtools/ADB.tsx +++ /dev/null @@ -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 -): Promise { - 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 { - return await execADB( - `reverse tcp:${local} tcp:${remote}`, - device != null ? device : null, - ); -} diff --git a/src/plugins/reactdevtools/index.tsx b/src/plugins/reactdevtools/index.tsx index e6284e9a6..4e95eea00 100644 --- a/src/plugins/reactdevtools/index.tsx +++ b/src/plugins/reactdevtools/index.tsx @@ -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]); } } }