aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
Diffstat (limited to 'android')
-rw-r--r--android/main.c19
-rw-r--r--android/utils/mapfile.c2
2 files changed, 18 insertions, 3 deletions
diff --git a/android/main.c b/android/main.c
index 7ff7910..f00e1da 100644
--- a/android/main.c
+++ b/android/main.c
@@ -2778,11 +2778,24 @@ void android_emulation_setup( void )
{
int tries = 16;
int base_port = 5554;
+ int adb_host_port = 5037; // adb's default
int success = 0;
int s;
uint32_t guest_ip;
- AndroidOptions* opts = qemulator->opts;
+ /* Set the port where the emulator expects adb to run on the host
+ * machine */
+ char* adb_host_port_str = getenv( "ANDROID_ADB_SERVER_PORT" );
+ if ( adb_host_port_str && strlen( adb_host_port_str ) > 0 ) {
+ adb_host_port = (int) strtol( adb_host_port_str, NULL, 0 );
+ if ( adb_host_port <= 0 ) {
+ derror( "env var ANDROID_ADB_SERVER_PORT must be a number > 0. Got \"%s\"\n",
+ adb_host_port_str );
+ exit(1);
+ }
+ }
+
+ AndroidOptions* opts = qemulator->opts;
inet_strtoip("10.0.2.15", &guest_ip);
@@ -2820,6 +2833,8 @@ void android_emulation_setup( void )
exit(1);
}
+ // Set up redirect from host to guest system. adbd on the guest listens
+ // on 5555.
slirp_redir( 0, adb_port, guest_ip, 5555 );
if ( control_console_start( console_port ) < 0 ) {
slirp_unredir( 0, adb_port );
@@ -2889,7 +2904,7 @@ void android_emulation_setup( void )
break;
}
- sock_address_init_inet( &addr, SOCK_ADDRESS_INET_LOOPBACK, 5037 );
+ sock_address_init_inet( &addr, SOCK_ADDRESS_INET_LOOPBACK, adb_host_port );
if (socket_connect( s, &addr ) < 0) {
D("can't connect to ADB server: %s", errno_str );
break;
diff --git a/android/utils/mapfile.c b/android/utils/mapfile.c
index f964d38..c8ba8e5 100644
--- a/android/utils/mapfile.c
+++ b/android/utils/mapfile.c
@@ -19,7 +19,7 @@
#include "sys/types.h"
#include "errno.h"
#ifdef WIN32
-#include "Windows.h"
+#include "windows.h"
#else // WIN32
#include <sys/mman.h>
#endif // WIN32