-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from bobrofon/main
Fix build with CGO_ENABLED=0 GOOS=android
- Loading branch information
Showing
4 changed files
with
56 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//go:build !(android && cgo) | ||
|
||
package anet | ||
|
||
func androidDeviceApiLevel() int { | ||
return -1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
//go:build android && cgo | ||
|
||
package anet | ||
|
||
// #include <android/api-level.h> | ||
import "C" | ||
|
||
import "sync" | ||
|
||
var ( | ||
apiLevel int | ||
once sync.Once | ||
) | ||
|
||
// Returns the API level of the device we're actually running on, or -1 on failure. | ||
// The returned value is equivalent to the Java Build.VERSION.SDK_INT API. | ||
func androidDeviceApiLevel() int { | ||
once.Do(func() { | ||
apiLevel = int(C.android_get_device_api_level()) | ||
}) | ||
|
||
return apiLevel | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters