Skip to content

Commit a8ffc2f

Browse files
fix: Detect iOS devices as physical
1 parent 80fe10b commit a8ffc2f

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

test_runner/src/main/kotlin/ftl/client/google/AndroidCatalog.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object AndroidCatalog {
1717
private val modelMap: MutableMap<String, List<String>> = mutableMapOf()
1818
private val versionMap: MutableMap<String, List<String>> = mutableMapOf()
1919

20-
private fun deviceCatalog(projectId: String) = catalogMap.getOrPut(projectId) {
20+
private fun androidDeviceCatalog(projectId: String) = catalogMap.getOrPut(projectId) {
2121
GcTesting.get.testEnvironmentCatalog()
2222
.get("android")
2323
.setProjectId(projectId)
@@ -29,26 +29,31 @@ object AndroidCatalog {
2929
private fun AndroidDeviceCatalog.filterDevicesWithoutSupportedVersions() =
3030
setModels(models.filterNotNull().filter { it.supportedVersionIds?.isNotEmpty() ?: false })
3131

32-
fun getModels(projectId: String): List<AndroidModel> = deviceCatalog(projectId).models.orEmpty()
32+
fun getModels(projectId: String): List<AndroidModel> = androidDeviceCatalog(projectId).models.orEmpty()
3333

3434
fun supportedOrientations(projectId: String): List<Orientation> =
35-
deviceCatalog(projectId).runtimeConfiguration.orientations
35+
androidDeviceCatalog(projectId).runtimeConfiguration.orientations
3636

37-
internal fun getLocales(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.locales
37+
internal fun getLocales(projectId: String) = androidDeviceCatalog(projectId).runtimeConfiguration.locales
3838

3939
fun androidModelIds(projectId: String) =
40-
modelMap.getOrPut(projectId) { deviceCatalog(projectId).models.map { it.id } }
40+
modelMap.getOrPut(projectId) { androidDeviceCatalog(projectId).models.map { it.id } }
4141

4242
fun androidVersionIds(projectId: String) =
43-
versionMap.getOrPut(projectId) { deviceCatalog(projectId).versions.map { it.id } }
43+
versionMap.getOrPut(projectId) { androidDeviceCatalog(projectId).versions.map { it.id } }
4444

4545
fun isVirtualDevice(device: AndroidDevice?, projectId: String): Boolean = device
4646
?.androidModelId
4747
?.let { isVirtualDevice(it, projectId) }
4848
?: false
4949

5050
fun isVirtualDevice(modelId: String, projectId: String): Boolean {
51-
val form = deviceCatalog(projectId).models
51+
// iOS catalog raises errors due to FTL backend blocking access from non-white listed project ids
52+
// work around this by manually looking for iphone/ipad in the model id.
53+
val isIos = listOf("ipad", "iphone").any { modelId.contains(it, ignoreCase = true) }
54+
if (isIos) return false
55+
56+
val form = androidDeviceCatalog(projectId).models
5257
.find { it.id.equals(modelId, ignoreCase = true) }?.form
5358
?: DeviceType.PHYSICAL.name.also {
5459
ReportManagerState.Log(

0 commit comments

Comments
 (0)