Android support (#244)

Add Android support

### Motivation:

Support the Android platform.

### Modifications:

Add Android imports and fix the default temporary directory to be
correct for the OS.

### Result:

The package will build and test on Android.

---------

Co-authored-by: George Barnett <gbarnett@apple.com>
This commit is contained in:
Marc Prud'hommeaux 2025-01-14 11:48:42 -05:00 committed by GitHub
parent 74a143a79f
commit aa0d902637
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 14 additions and 0 deletions

View File

@ -17,6 +17,8 @@ import NIOCore
import Darwin
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#else
import Glibc
#endif

View File

@ -18,6 +18,8 @@ import NIOCore
import Darwin
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#else
import Glibc
#endif

View File

@ -20,6 +20,8 @@ import NIOCore
import Darwin
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#else
import Glibc
#endif

View File

@ -19,6 +19,8 @@ import NIOCore
import Darwin
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#else
import Glibc
#endif

View File

@ -108,6 +108,8 @@ private func withTemporaryFile<T>(
private var temporaryDirectory: String {
#if os(Linux)
return "/tmp"
#elseif os(Android)
return "/data/local/tmp"
#else
if #available(macOS 10.12, iOS 10, tvOS 10, watchOS 3, *) {
return FileManager.default.temporaryDirectory.path

View File

@ -19,6 +19,10 @@ import XCTest
@testable import NIOExtras
#if canImport(Android)
import Android
#endif
class WritePCAPHandlerTest: XCTestCase {
private var accumulatedPackets: [ByteBuffer]!
private var channel: EmbeddedChannel!