Skip to content

Commit e8b94e7

Browse files
committed
Initial commit
1 parent 495aec1 commit e8b94e7

File tree

9 files changed

+88
-1
lines changed

9 files changed

+88
-1
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.github.jan.supabase
2+
3+
internal actual val OSInformation: OSInformation = OSInformation(
4+
name = "Android",
5+
version = android.os.Build.VERSION.SDK_INT.toString()
6+
)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.supabase.supabase
2+
3+
import kotlinx.cinterop.ExperimentalForeignApi
4+
import kotlinx.cinterop.UnsafeNumber
5+
import kotlinx.cinterop.useContents
6+
7+
@OptIn(ExperimentalForeignApi::class, UnsafeNumber::class)
8+
internal fun getOSVersion(): String {
9+
val processInfo = platform.Foundation.NSProcessInfo.processInfo
10+
return processInfo.operatingSystemVersion.useContents {
11+
val majorVersion = this.majorVersion
12+
val minorVersion = this.minorVersion
13+
val patchVersion = this.patchVersion
14+
buildString {
15+
append(majorVersion)
16+
append(".")
17+
append(minorVersion)
18+
append(".")
19+
append(patchVersion)
20+
}
21+
}
22+
}

Supabase/src/commonMain/kotlin/io/github/jan/supabase/PlatformTarget.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ enum class PlatformTarget {
88
JVM, ANDROID, JS, WASM_JS, IOS, WINDOWS, MACOS, TVOS, WATCHOS, LINUX;
99
}
1010

11+
internal data class OSInformation(
12+
val name: String,
13+
val version: String
14+
)
15+
1116
/**
1217
* The current target platform
1318
*/
14-
expect val CurrentPlatformTarget: PlatformTarget
19+
expect val CurrentPlatformTarget: PlatformTarget
20+
21+
/**
22+
* The current operating system information
23+
*/
24+
internal expect val OSInformation: OSInformation
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.github.jan.supabase
2+
3+
import io.supabase.supabase.getOSVersion
4+
5+
internal actual val OSInformation: OSInformation = OSInformation(
6+
name = "iOS",
7+
version = getOSVersion()
8+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package io.github.jan.supabase
2+
3+
internal actual val OSInformation: OSInformation = OSInformation(
4+
name = System.getProperty("os.name"),
5+
version = System.getProperty("os.version")
6+
)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package io.github.jan.supabase
2+
3+
actual val OSInformation: OSInformation = OSInformation(
4+
name = "Linux",
5+
version = getOSVersion()
6+
)
7+
8+
private fun getOSVersion(): String {
9+
//Get OS Version, this is from Native Linux code:
10+
KERN
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.github.jan.supabase
2+
3+
import io.supabase.supabase.getOSVersion
4+
5+
internal actual val OSInformation: OSInformation = OSInformation(
6+
name = "macOS",
7+
version = getOSVersion()
8+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.github.jan.supabase
2+
3+
import io.supabase.supabase.getOSVersion
4+
5+
internal actual val OSInformation: OSInformation = OSInformation(
6+
name = "tvOS",
7+
version = getOSVersion()
8+
)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.github.jan.supabase
2+
3+
import io.supabase.supabase.getOSVersion
4+
5+
internal actual val OSInformation: OSInformation = OSInformation(
6+
name = "watchOS",
7+
version = getOSVersion()
8+
)

0 commit comments

Comments
 (0)