Skip to content

Commit

Permalink
Android support (#244)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
marcprux and glbrntt authored Jan 14, 2025
1 parent 74a143a commit aa0d902
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Sources/NIOExtras/DebugInboundEventsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import NIOCore
import Darwin
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#else
import Glibc
#endif
Expand Down
2 changes: 2 additions & 0 deletions Sources/NIOExtras/DebugOutboundEventsHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import NIOCore
import Darwin
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#else
import Glibc
#endif
Expand Down
2 changes: 2 additions & 0 deletions Sources/NIOExtras/WritePCAPHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import NIOCore
import Darwin
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#else
import Glibc
#endif
Expand Down
2 changes: 2 additions & 0 deletions Sources/NIOSOCKS/Messages/SOCKSRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import NIOCore
import Darwin
#elseif canImport(Musl)
import Musl
#elseif canImport(Android)
import Android
#else
import Glibc
#endif
Expand Down
2 changes: 2 additions & 0 deletions Tests/NIOExtrasTests/SynchronizedFileSinkTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Tests/NIOExtrasTests/WritePCAPHandlerTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down

0 comments on commit aa0d902

Please sign in to comment.