diff --git a/libserialport_internal.h b/libserialport_internal.h index 0ad6f70..35aa6f9 100644 --- a/libserialport_internal.h +++ b/libserialport_internal.h @@ -68,8 +68,9 @@ #endif #ifdef __linux__ #include -#ifndef __ANDROID__ -#include "linux/serial.h" +/* Android only has linux/serial.h from platform 21 onwards. */ +#if !(defined(__ANDROID__) && (__ANDROID_API__ < 21)) +#include #endif #include "linux_termios.h" diff --git a/serialport.c b/serialport.c index 9e56e89..c233b28 100644 --- a/serialport.c +++ b/serialport.c @@ -742,7 +742,9 @@ SP_API enum sp_return sp_drain(struct sp_port *port) #else int result; while (1) { -#ifdef __ANDROID__ +#if defined(__ANDROID__) && (__ANDROID_API__ < 21) + /* Android only has tcdrain from platform 21 onwards. + * On previous API versions, use the ioctl directly. */ int arg = 1; result = ioctl(port->fd, TCSBRK, &arg); #else