Run adb reverse for emulators too

Summary:
Yesterday I made a change that switches from hardcoded IP address 10.0.2.2, to localhost for emulators on Android 5+.
This didn't work with flipper because it relies on port forwarding, and port forwarding was only done for physical devices, not emulators.

This corrects that, by port forwarding whenever possible. This will enable using localhost, which simplifies remote adb connection support.

Reviewed By: danielbuechele

Differential Revision: D10255554

fbshipit-source-id: 77a05eddf530e0e9495568f2a0901f390464345a
This commit is contained in:
John Knox
2018-10-09 06:22:13 -07:00
committed by Facebook Github Bot
parent 76ad9e90cc
commit 1a5b127d58

View File

@@ -10,6 +10,7 @@ import type {DeviceType, DeviceShell} from './BaseDevice.js';
import {Priority} from 'adbkit-logcat-fb';
import child_process from 'child_process';
import BaseDevice from './BaseDevice.js';
import {SECURE_PORT, INSECURE_PORT} from '../server';
type ADBClient = any;
@@ -79,13 +80,15 @@ export default class AndroidDevice extends BaseDevice {
}
reverse(): Promise<void> {
if (this.deviceType === 'physical') {
return this.adb
.reverse(this.serial, 'tcp:8088', 'tcp:8088')
.then(_ => this.adb.reverse(this.serial, 'tcp:8089', 'tcp:8089'));
} else {
return Promise.resolve();
}
return this.adb
.reverse(this.serial, `tcp:${SECURE_PORT}`, `tcp:${SECURE_PORT}`)
.then(() =>
this.adb.reverse(
this.serial,
`tcp:${INSECURE_PORT}`,
`tcp:${INSECURE_PORT}`,
),
);
}
spawnShell(): DeviceShell {