diff --git a/tealiumlibrary/build.gradle b/tealiumlibrary/build.gradle index 875cdfde..f8550202 100644 --- a/tealiumlibrary/build.gradle +++ b/tealiumlibrary/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'maven-publish' apply plugin: 'kotlin-allopen' apply from: '../jacoco.gradle' -version = '1.2.6' +version = '1.2.7' android { compileSdkVersion 29 diff --git a/tealiumlibrary/src/androidTest/java/com/tealium/core/collection/DeviceCollectorTests.kt b/tealiumlibrary/src/androidTest/java/com/tealium/core/collection/DeviceCollectorTests.kt index 2d144423..d806b7fe 100644 --- a/tealiumlibrary/src/androidTest/java/com/tealium/core/collection/DeviceCollectorTests.kt +++ b/tealiumlibrary/src/androidTest/java/com/tealium/core/collection/DeviceCollectorTests.kt @@ -73,6 +73,7 @@ class DeviceCollectorTests { assertEquals("Android", data[DeviceCollectorConstants.DEVICE_OS_NAME]) assertNotNull(data[DeviceCollectorConstants.DEVICE_RUNTIME]) assertTrue("[0-9]+x[0-9]+".toRegex().matches(data[DeviceCollectorConstants.DEVICE_RESOLUTION] as String)) + assertTrue("[0-9]+x[0-9]+".toRegex().matches(data[DeviceCollectorConstants.DEVICE_LOGICAL_RESOLUTION] as String)) assertSame(DeviceCollector.create(tealiumContext), DeviceCollector.create(tealiumContext)) } diff --git a/tealiumlibrary/src/main/java/com/tealium/core/collection/DeviceCollector.kt b/tealiumlibrary/src/main/java/com/tealium/core/collection/DeviceCollector.kt index 8d10949f..31885e58 100644 --- a/tealiumlibrary/src/main/java/com/tealium/core/collection/DeviceCollector.kt +++ b/tealiumlibrary/src/main/java/com/tealium/core/collection/DeviceCollector.kt @@ -20,6 +20,7 @@ interface DeviceData { val deviceArchitecture: String val deviceCpuType: String val deviceResolution: String + val deviceLogicalResolution: String val deviceRuntime: String val deviceOrigin: String val devicePlatform: String @@ -43,17 +44,23 @@ class DeviceCollector private constructor(context: Context) : Collector, DeviceD private val point = Point() override val device = if (Build.MODEL.startsWith(Build.MANUFACTURER)) Build.MODEL - ?: "" else "${Build.MANUFACTURER} ${Build.MODEL}" + ?: "" else "${Build.MANUFACTURER} ${Build.MODEL}" override val deviceModel: String = Build.MODEL override val deviceManufacturer: String = Build.MANUFACTURER - override val deviceArchitecture = if (Build.SUPPORTED_64_BIT_ABIS.isNotEmpty()) "64bit" else "32bit" + override val deviceArchitecture = + if (Build.SUPPORTED_64_BIT_ABIS.isNotEmpty()) "64bit" else "32bit" override val deviceCpuType = System.getProperty("os.arch") ?: "unknown" override val deviceResolution = point.let { windowManager.defaultDisplay.getSize(it) "${it.x}x${it.y}" } + override val deviceLogicalResolution = point.let { + windowManager.defaultDisplay.getRealSize(it) + "${it.x}x${it.y}" + } override val deviceRuntime = System.getProperty("java.vm.version") ?: "unknown" - override val deviceOrigin = if (uiModeManager.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION) "tv" else "mobile" + override val deviceOrigin = + if (uiModeManager.currentModeType == Configuration.UI_MODE_TYPE_TELEVISION) "tv" else "mobile" override val devicePlatform = "android" override val deviceOsName = "Android" override val deviceOsBuild = Build.VERSION.INCREMENTAL ?: "" @@ -85,30 +92,32 @@ class DeviceCollector private constructor(context: Context) : Collector, DeviceD override suspend fun collect(): Map { return mapOf( - DeviceCollectorConstants.DEVICE to device, - DeviceCollectorConstants.DEVICE_MODEL to deviceModel, - DeviceCollectorConstants.DEVICE_MANUFACTURER to deviceManufacturer, - DeviceCollectorConstants.DEVICE_ARCHITECTURE to deviceArchitecture, - DeviceCollectorConstants.DEVICE_CPU_TYPE to deviceCpuType, - DeviceCollectorConstants.DEVICE_RESOLUTION to deviceResolution, - DeviceCollectorConstants.DEVICE_RUNTIME to deviceRuntime, - DeviceCollectorConstants.DEVICE_ORIGIN to deviceOrigin, - DeviceCollectorConstants.DEVICE_PLATFORM to devicePlatform, - DeviceCollectorConstants.DEVICE_OS_NAME to deviceOsName, - DeviceCollectorConstants.DEVICE_OS_BUILD to deviceOsBuild, - DeviceCollectorConstants.DEVICE_OS_VERSION to deviceOsVersion, - DeviceCollectorConstants.DEVICE_AVAILABLE_SYSTEM_STORAGE to deviceAvailableSystemStorage, - DeviceCollectorConstants.DEVICE_AVAILABLE_EXTERNAL_STORAGE to deviceAvailableExternalStorage, - DeviceCollectorConstants.DEVICE_ORIENTATION to deviceOrientation, - DeviceCollectorConstants.DEVICE_LANGUAGE to deviceLanguage + DeviceCollectorConstants.DEVICE to device, + DeviceCollectorConstants.DEVICE_MODEL to deviceModel, + DeviceCollectorConstants.DEVICE_MANUFACTURER to deviceManufacturer, + DeviceCollectorConstants.DEVICE_ARCHITECTURE to deviceArchitecture, + DeviceCollectorConstants.DEVICE_CPU_TYPE to deviceCpuType, + DeviceCollectorConstants.DEVICE_RESOLUTION to deviceResolution, + DeviceCollectorConstants.DEVICE_LOGICAL_RESOLUTION to deviceLogicalResolution, + DeviceCollectorConstants.DEVICE_RUNTIME to deviceRuntime, + DeviceCollectorConstants.DEVICE_ORIGIN to deviceOrigin, + DeviceCollectorConstants.DEVICE_PLATFORM to devicePlatform, + DeviceCollectorConstants.DEVICE_OS_NAME to deviceOsName, + DeviceCollectorConstants.DEVICE_OS_BUILD to deviceOsBuild, + DeviceCollectorConstants.DEVICE_OS_VERSION to deviceOsVersion, + DeviceCollectorConstants.DEVICE_AVAILABLE_SYSTEM_STORAGE to deviceAvailableSystemStorage, + DeviceCollectorConstants.DEVICE_AVAILABLE_EXTERNAL_STORAGE to deviceAvailableExternalStorage, + DeviceCollectorConstants.DEVICE_ORIENTATION to deviceOrientation, + DeviceCollectorConstants.DEVICE_LANGUAGE to deviceLanguage ) } companion object : CollectorFactory { const val MODULE_VERSION = BuildConfig.LIBRARY_VERSION - @Volatile private var instance: Collector? = null + @Volatile + private var instance: Collector? = null - override fun create(context: TealiumContext): Collector = instance ?: synchronized(this){ + override fun create(context: TealiumContext): Collector = instance ?: synchronized(this) { instance ?: DeviceCollector(context.config.application).also { instance = it } } } diff --git a/tealiumlibrary/src/main/java/com/tealium/core/collection/DeviceCollectorConstants.kt b/tealiumlibrary/src/main/java/com/tealium/core/collection/DeviceCollectorConstants.kt index 7d7801d0..83ad5128 100644 --- a/tealiumlibrary/src/main/java/com/tealium/core/collection/DeviceCollectorConstants.kt +++ b/tealiumlibrary/src/main/java/com/tealium/core/collection/DeviceCollectorConstants.kt @@ -7,6 +7,7 @@ object DeviceCollectorConstants { const val DEVICE_ARCHITECTURE = "device_architecture" const val DEVICE_CPU_TYPE = "device_cputype" const val DEVICE_RESOLUTION = "device_resolution" + const val DEVICE_LOGICAL_RESOLUTION = "device_logical_resolution" const val DEVICE_RUNTIME = "device_android_runtime" const val DEVICE_ORIGIN = "origin" const val DEVICE_PLATFORM = "platform"