-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- unified networking config in an environmentController new componen…
…t that also can provide information of the device (#106) - can detect if running on simulator
- Loading branch information
Showing
6 changed files
with
93 additions
and
25 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...n/src/androidMain/kotlin/network/bisq/mobile/domain/data/EnvironmentController.android.kt
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,46 @@ | ||
package network.bisq.mobile.domain.data | ||
|
||
import network.bisq.mobile.client.shared.BuildConfig | ||
|
||
// on android there is no 100% accurate way to determine, but this is the most comprehesive one | ||
actual fun provideIsSimulator(): Boolean { | ||
println("Fingerprint ${android.os.Build.FINGERPRINT}") | ||
return (android.os.Build.MANUFACTURER == "Google" && android.os.Build.BRAND == "google" && | ||
((android.os.Build.FINGERPRINT.startsWith("google/sdk_gphone_") | ||
&& android.os.Build.FINGERPRINT.endsWith(":user/release-keys") | ||
&& android.os.Build.PRODUCT.startsWith("sdk_gphone_") | ||
&& android.os.Build.MODEL.startsWith("sdk_gphone_")) | ||
//alternative | ||
|| (android.os.Build.FINGERPRINT.startsWith("google/sdk_gphone64_") && (android.os.Build.FINGERPRINT.endsWith(":userdebug/dev-keys") | ||
|| (android.os.Build.FINGERPRINT.endsWith(":user/release-keys")) && android.os.Build.PRODUCT.startsWith("sdk_gphone64_") | ||
&& android.os.Build.MODEL.startsWith("sdk_gphone64_"))) | ||
//Google Play Games emulator https://play.google.com/googleplaygames https://developer.android.com/games/playgames/emulator#other-downloads | ||
|| (android.os.Build.MODEL == "HPE device" && | ||
android.os.Build.FINGERPRINT.startsWith("google/kiwi_") && android.os.Build.FINGERPRINT.endsWith(":user/release-keys") | ||
&& android.os.Build.BOARD == "kiwi" && android.os.Build.PRODUCT.startsWith("kiwi_")) | ||
) | ||
// | ||
|| android.os.Build.FINGERPRINT.startsWith("generic") | ||
|| android.os.Build.FINGERPRINT.startsWith("unknown") | ||
|| android.os.Build.MODEL.contains("google_sdk") | ||
|| android.os.Build.MODEL.contains("Emulator") | ||
|| android.os.Build.MODEL.contains("Android SDK built for x86") | ||
//bluestacks | ||
|| "QC_Reference_Phone" == android.os.Build.BOARD && !"Xiaomi".equals(android.os.Build.MANUFACTURER, ignoreCase = true) | ||
//bluestacks | ||
|| android.os.Build.MANUFACTURER.contains("Genymotion") | ||
|| android.os.Build.HOST.startsWith("Build") | ||
//MSI App Player | ||
|| android.os.Build.BRAND.startsWith("generic") && android.os.Build.DEVICE.startsWith("generic") | ||
|| android.os.Build.PRODUCT == "google_sdk" | ||
// another Android SDK emulator check | ||
|| System.getProperties()["ro.kernel.qemu"] == "1") | ||
} | ||
|
||
actual fun provideApiHost(): String { | ||
return BuildConfig.WS_ANDROID_HOST.takeIf { it.isNotEmpty() } ?: "10.0.2.2" | ||
} | ||
|
||
actual fun provideApiPort(): Int { | ||
return (BuildConfig.WS_PORT.takeIf { it.isNotEmpty() } ?: "8090").toInt() | ||
} |
2 changes: 0 additions & 2 deletions
2
shared/domain/src/appleMain/kotlin/network/bisq/mobile/service/IosImageUtil.kt
This file was deleted.
Oops, something went wrong.
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
22 changes: 22 additions & 0 deletions
22
shared/domain/src/commonMain/kotlin/network/bisq/mobile/domain/data/EnvironmentController.kt
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,22 @@ | ||
package network.bisq.mobile.domain.data | ||
|
||
/** | ||
* Provides environment config. | ||
*/ | ||
class EnvironmentController { | ||
fun getApiHost(): String = provideApiHost() | ||
|
||
fun getApiPort(): Int = provideApiPort() | ||
|
||
fun getWebSocketHost(): String = provideApiHost() | ||
|
||
fun getWebSocketPort(): Int = provideApiPort() | ||
|
||
fun isSimulator(): Boolean = provideIsSimulator() | ||
} | ||
|
||
expect fun provideIsSimulator(): Boolean | ||
|
||
expect fun provideApiHost(): String | ||
|
||
expect fun provideApiPort(): Int |
17 changes: 17 additions & 0 deletions
17
...ed/domain/src/iosMain/kotlin/network/bisq/mobile/domain/data/EnvironmentController.ios.kt
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,17 @@ | ||
package network.bisq.mobile.domain.data | ||
|
||
import network.bisq.mobile.client.shared.BuildConfig | ||
import platform.Foundation.NSProcessInfo | ||
|
||
actual fun provideIsSimulator(): Boolean { | ||
val deviceModel = NSProcessInfo.processInfo.environment["SIMULATOR_DEVICE_NAME"] as? String | ||
return deviceModel != null | ||
} | ||
|
||
actual fun provideApiHost(): String { | ||
return BuildConfig.WS_IOS_HOST.takeIf { it.isNotEmpty() } ?: "localhost" | ||
} | ||
|
||
actual fun provideApiPort(): Int { | ||
return (BuildConfig.WS_PORT.takeIf { it.isNotEmpty() } ?: "8090").toInt() | ||
} |
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