diff --git a/droid-dex/src/main/kotlin/com/blinkit/droiddex/factory/base/PerformanceManager.kt b/droid-dex/src/main/kotlin/com/blinkit/droiddex/factory/base/PerformanceManager.kt index 8f9c5a7..8c5dd96 100644 --- a/droid-dex/src/main/kotlin/com/blinkit/droiddex/factory/base/PerformanceManager.kt +++ b/droid-dex/src/main/kotlin/com/blinkit/droiddex/factory/base/PerformanceManager.kt @@ -6,9 +6,14 @@ import com.blinkit.droiddex.constants.PerformanceClass import com.blinkit.droiddex.constants.PerformanceLevel import com.blinkit.droiddex.utils.Logger import com.blinkit.droiddex.utils.runAsyncPeriodically +import kotlin.concurrent.Volatile internal abstract class PerformanceManager(private val isInDebugMode: Boolean) { + @Volatile + var performanceLevel = PerformanceLevel.UNKNOWN + private set + private val _performanceLevelLd = MutableLiveData(PerformanceLevel.UNKNOWN) val performanceLevelLd: LiveData get() = _performanceLevelLd @@ -20,7 +25,10 @@ internal abstract class PerformanceManager(private val isInDebugMode: Boolean) { try { measurePerformanceLevel().also { val hasPerformanceLevelChanged = performanceLevelLd.value != it - if (hasPerformanceLevelChanged) _performanceLevelLd.postValue(it) + if (hasPerformanceLevelChanged) { + performanceLevel = it + _performanceLevelLd.postValue(it) + } logger.logPerformanceLevelChange(it, hasPerformanceLevelChanged) } } catch (e: Exception) { diff --git a/droid-dex/src/main/kotlin/com/blinkit/droiddex/factory/factory/PerformanceManagerFactory.kt b/droid-dex/src/main/kotlin/com/blinkit/droiddex/factory/factory/PerformanceManagerFactory.kt index 4faf69a..68ebbc1 100644 --- a/droid-dex/src/main/kotlin/com/blinkit/droiddex/factory/factory/PerformanceManagerFactory.kt +++ b/droid-dex/src/main/kotlin/com/blinkit/droiddex/factory/factory/PerformanceManagerFactory.kt @@ -20,7 +20,7 @@ internal class PerformanceManagerFactory(private val applicationContext: Context } fun getPerformanceLevel(@PerformanceClass performanceClass: Int): PerformanceLevel = - getOrPut(performanceClass).performanceLevelLd.value ?: PerformanceLevel.UNKNOWN + getOrPut(performanceClass).performanceLevel fun getPerformanceLevelLd(@PerformanceClass performanceClass: Int): LiveData = getOrPut(performanceClass).performanceLevelLd diff --git a/gradle.properties b/gradle.properties index d966f1c..0a15f7f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -42,7 +42,7 @@ org.gradle.configuration-cache-problems=warn # Maven Publishing GROUP=com.blinkit.kits POM_ARTIFACT_ID=droid-dex -VERSION_NAME=2.0.0 +VERSION_NAME=2.0.1 POM_NAME=Droid Dex POM_DESCRIPTION=Classification and Analysis of Android Device Performance