Skip to content

Commit

Permalink
FIX | Initial Performance Level (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
krayong-work authored Apr 4, 2024
1 parent 820bd53 commit 7d4250d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<PerformanceLevel>
get() = _performanceLevelLd
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PerformanceLevel> =
getOrPut(performanceClass).performanceLevelLd
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7d4250d

Please sign in to comment.