[SHARED] Refactor CPU data flow
This commit is contained in:
+11
-93
@@ -15,33 +15,26 @@
|
||||
*/
|
||||
package com.kgurgul.cpuinfo.tv.features.information.cpu
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.kgurgul.cpuinfo.domain.model.CpuData
|
||||
import com.kgurgul.cpuinfo.domain.model.getName
|
||||
import com.kgurgul.cpuinfo.domain.model.getValue
|
||||
import com.kgurgul.cpuinfo.features.information.base.InformationRow
|
||||
import com.kgurgul.cpuinfo.features.information.cpu.CpuInfoViewModel
|
||||
import com.kgurgul.cpuinfo.shared.Res
|
||||
import com.kgurgul.cpuinfo.shared.cpu_abi
|
||||
import com.kgurgul.cpuinfo.shared.cpu_cores
|
||||
import com.kgurgul.cpuinfo.shared.cpu_current_frequency
|
||||
import com.kgurgul.cpuinfo.shared.cpu_frequency_stopped
|
||||
import com.kgurgul.cpuinfo.shared.cpu_has_neon
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l1d
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l1i
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l2
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l3
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l4
|
||||
import com.kgurgul.cpuinfo.shared.cpu_soc_name
|
||||
import com.kgurgul.cpuinfo.shared.no
|
||||
import com.kgurgul.cpuinfo.shared.yes
|
||||
import com.kgurgul.cpuinfo.tv.ui.components.TvListItem
|
||||
import com.kgurgul.cpuinfo.ui.components.CpuProgressBar
|
||||
import com.kgurgul.cpuinfo.ui.components.ItemValueRow
|
||||
import com.kgurgul.cpuinfo.ui.theme.spacingSmall
|
||||
import com.kgurgul.cpuinfo.utils.formatHz
|
||||
import org.jetbrains.compose.resources.stringResource
|
||||
@@ -57,6 +50,7 @@ fun TvCpuInfoScreen(viewModel: CpuInfoViewModel = koinViewModel()) {
|
||||
fun TvCpuInfoScreen(uiState: CpuInfoViewModel.UiState) {
|
||||
LazyColumn(
|
||||
contentPadding = PaddingValues(spacingSmall),
|
||||
verticalArrangement = Arrangement.spacedBy(spacingSmall),
|
||||
modifier = Modifier.fillMaxSize().testTag(TvCpuInfoScreenTestTags.LAZY_COLUMN),
|
||||
) {
|
||||
uiState.cpuData?.let { cpuData ->
|
||||
@@ -65,91 +59,15 @@ fun TvCpuInfoScreen(uiState: CpuInfoViewModel.UiState) {
|
||||
TvListItem { FrequencyItem(index = i, frequency = frequency) }
|
||||
}
|
||||
}
|
||||
item(key = "__soc_name") {
|
||||
items(cpuData.cpuItems) { itemValue ->
|
||||
TvListItem {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_soc_name),
|
||||
value = cpuData.processorName,
|
||||
modifier = Modifier.testTag(TvCpuInfoScreenTestTags.SOCKET_NAME),
|
||||
InformationRow(
|
||||
title = itemValue.getName(),
|
||||
value = itemValue.getValue(),
|
||||
isLastItem = true,
|
||||
)
|
||||
}
|
||||
}
|
||||
item(key = "__abi") {
|
||||
TvListItem {
|
||||
ItemValueRow(title = stringResource(Res.string.cpu_abi), value = cpuData.abi)
|
||||
}
|
||||
}
|
||||
item(key = "__cores") {
|
||||
TvListItem {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_cores),
|
||||
value = cpuData.coreNumber.toString(),
|
||||
)
|
||||
}
|
||||
}
|
||||
item(key = "__has_neon") {
|
||||
TvListItem {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_has_neon),
|
||||
value =
|
||||
if (cpuData.hasArmNeon) {
|
||||
stringResource(Res.string.yes)
|
||||
} else {
|
||||
stringResource(Res.string.no)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l1dCaches.isNotEmpty()) {
|
||||
item(key = "__l1d") {
|
||||
TvListItem {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l1d),
|
||||
value = cpuData.l1dCaches,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cpuData.l1iCaches.isNotEmpty()) {
|
||||
item(key = "__l1i") {
|
||||
TvListItem {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l1i),
|
||||
value = cpuData.l1iCaches,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cpuData.l2Caches.isNotEmpty()) {
|
||||
item(key = "__l2") {
|
||||
TvListItem {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l2),
|
||||
value = cpuData.l2Caches,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cpuData.l3Caches.isNotEmpty()) {
|
||||
item(key = "__l3") {
|
||||
TvListItem {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l3),
|
||||
value = cpuData.l3Caches,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cpuData.l4Caches.isNotEmpty()) {
|
||||
item(key = "__l4") {
|
||||
TvListItem {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l4),
|
||||
value = cpuData.l4Caches,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+14
-1
@@ -15,13 +15,19 @@
|
||||
*/
|
||||
package com.kgurgul.cpuinfo.data.provider
|
||||
|
||||
import com.kgurgul.cpuinfo.domain.model.ItemValue
|
||||
import com.kgurgul.cpuinfo.shared.Res
|
||||
import com.kgurgul.cpuinfo.shared.cpu_has_neon
|
||||
import com.kgurgul.cpuinfo.shared.no
|
||||
import com.kgurgul.cpuinfo.shared.yes
|
||||
|
||||
actual class CpuDataNativeProvider actual constructor() : ICpuDataNativeProvider {
|
||||
|
||||
actual external override fun initLibrary()
|
||||
|
||||
actual external override fun getCpuName(): String
|
||||
|
||||
actual external override fun hasArmNeon(): Boolean
|
||||
private external fun hasArmNeon(): Boolean
|
||||
|
||||
actual external override fun getL1dCaches(): IntArray?
|
||||
|
||||
@@ -34,4 +40,11 @@ actual class CpuDataNativeProvider actual constructor() : ICpuDataNativeProvider
|
||||
actual external override fun getL4Caches(): IntArray?
|
||||
|
||||
actual external override fun getNumberOfCores(): Int
|
||||
|
||||
override fun getExtraItems(): List<ItemValue> = listOf(
|
||||
ItemValue.NameValueResource(
|
||||
name = Res.string.cpu_has_neon,
|
||||
value = if (hasArmNeon()) Res.string.yes else Res.string.no,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
-2
@@ -21,8 +21,6 @@ expect class CpuDataNativeProvider() : ICpuDataNativeProvider {
|
||||
|
||||
override fun getCpuName(): String
|
||||
|
||||
override fun hasArmNeon(): Boolean
|
||||
|
||||
override fun getL1dCaches(): IntArray?
|
||||
|
||||
override fun getL1iCaches(): IntArray?
|
||||
|
||||
+4
-2
@@ -15,14 +15,14 @@
|
||||
*/
|
||||
package com.kgurgul.cpuinfo.data.provider
|
||||
|
||||
import com.kgurgul.cpuinfo.domain.model.ItemValue
|
||||
|
||||
interface ICpuDataNativeProvider {
|
||||
|
||||
fun initLibrary()
|
||||
|
||||
fun getCpuName(): String
|
||||
|
||||
fun hasArmNeon(): Boolean
|
||||
|
||||
fun getL1dCaches(): IntArray?
|
||||
|
||||
fun getL1iCaches(): IntArray?
|
||||
@@ -34,4 +34,6 @@ interface ICpuDataNativeProvider {
|
||||
fun getL4Caches(): IntArray?
|
||||
|
||||
fun getNumberOfCores(): Int
|
||||
|
||||
fun getExtraItems(): List<ItemValue> = emptyList()
|
||||
}
|
||||
|
||||
@@ -19,16 +19,8 @@ import androidx.compose.runtime.Stable
|
||||
|
||||
@Stable
|
||||
data class CpuData(
|
||||
val processorName: String,
|
||||
val abi: String,
|
||||
val coreNumber: Int,
|
||||
val hasArmNeon: Boolean,
|
||||
val cpuItems: List<ItemValue>,
|
||||
val frequencies: List<Frequency>,
|
||||
val l1dCaches: String,
|
||||
val l1iCaches: String,
|
||||
val l2Caches: String,
|
||||
val l3Caches: String,
|
||||
val l4Caches: String,
|
||||
) {
|
||||
|
||||
data class Frequency(val min: Long, val max: Long, val current: Long)
|
||||
|
||||
+32
-10
@@ -19,6 +19,16 @@ import com.kgurgul.cpuinfo.data.provider.ICpuDataNativeProvider
|
||||
import com.kgurgul.cpuinfo.data.provider.ICpuDataProvider
|
||||
import com.kgurgul.cpuinfo.domain.ImmutableInteractor
|
||||
import com.kgurgul.cpuinfo.domain.model.CpuData
|
||||
import com.kgurgul.cpuinfo.domain.model.ItemValue
|
||||
import com.kgurgul.cpuinfo.shared.Res
|
||||
import com.kgurgul.cpuinfo.shared.cpu_abi
|
||||
import com.kgurgul.cpuinfo.shared.cpu_cores
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l1d
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l1i
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l2
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l3
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l4
|
||||
import com.kgurgul.cpuinfo.shared.cpu_soc_name
|
||||
import com.kgurgul.cpuinfo.utils.IDispatchersProvider
|
||||
import com.kgurgul.cpuinfo.utils.Utils
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -38,7 +48,6 @@ class CpuDataObservable(
|
||||
val abi = cpuDataProvider.getAbi()
|
||||
val logicalCoresCount = cpuDataProvider.getNumberOfLogicalCores()
|
||||
val physicalCoresCount = cpuDataProvider.getNumberOfPhysicalCores()
|
||||
val hasArmNeon = cpuDataNativeProvider.hasArmNeon()
|
||||
val frequencies = mutableListOf<CpuData.Frequency>()
|
||||
val l1dCaches =
|
||||
cpuDataNativeProvider.getL1dCaches()?.joinToString(separator = "\n") {
|
||||
@@ -67,18 +76,31 @@ class CpuDataObservable(
|
||||
frequencies.add(CpuData.Frequency(min, max, current))
|
||||
}
|
||||
}
|
||||
val cpuItems = buildList {
|
||||
add(ItemValue.NameResource(Res.string.cpu_soc_name, processorName))
|
||||
add(ItemValue.NameResource(Res.string.cpu_abi, abi))
|
||||
add(ItemValue.NameResource(Res.string.cpu_cores, physicalCoresCount.toString()))
|
||||
addAll(cpuDataNativeProvider.getExtraItems())
|
||||
if (l1dCaches.isNotEmpty()) {
|
||||
add(ItemValue.NameResource(Res.string.cpu_l1d, l1dCaches))
|
||||
}
|
||||
if (l1iCaches.isNotEmpty()) {
|
||||
add(ItemValue.NameResource(Res.string.cpu_l1i, l1iCaches))
|
||||
}
|
||||
if (l2Caches.isNotEmpty()) {
|
||||
add(ItemValue.NameResource(Res.string.cpu_l2, l2Caches))
|
||||
}
|
||||
if (l3Caches.isNotEmpty()) {
|
||||
add(ItemValue.NameResource(Res.string.cpu_l3, l3Caches))
|
||||
}
|
||||
if (l4Caches.isNotEmpty()) {
|
||||
add(ItemValue.NameResource(Res.string.cpu_l4, l4Caches))
|
||||
}
|
||||
}
|
||||
emit(
|
||||
CpuData(
|
||||
processorName = processorName,
|
||||
abi = abi,
|
||||
coreNumber = physicalCoresCount,
|
||||
hasArmNeon = hasArmNeon,
|
||||
cpuItems = cpuItems,
|
||||
frequencies = frequencies,
|
||||
l1dCaches = l1dCaches,
|
||||
l1iCaches = l1iCaches,
|
||||
l2Caches = l2Caches,
|
||||
l3Caches = l3Caches,
|
||||
l4Caches = l4Caches,
|
||||
)
|
||||
)
|
||||
delay(REFRESH_DELAY)
|
||||
|
||||
+20
-108
@@ -17,11 +17,10 @@ package com.kgurgul.cpuinfo.features.information.cpu
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.requiredSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.lazy.rememberLazyListState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
@@ -31,24 +30,17 @@ import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import com.kgurgul.cpuinfo.domain.model.CpuData
|
||||
import com.kgurgul.cpuinfo.domain.model.ItemValue
|
||||
import com.kgurgul.cpuinfo.domain.model.getKey
|
||||
import com.kgurgul.cpuinfo.domain.model.getName
|
||||
import com.kgurgul.cpuinfo.domain.model.getValue
|
||||
import com.kgurgul.cpuinfo.features.information.base.InformationRow
|
||||
import com.kgurgul.cpuinfo.shared.Res
|
||||
import com.kgurgul.cpuinfo.shared.cpu_abi
|
||||
import com.kgurgul.cpuinfo.shared.cpu_cores
|
||||
import com.kgurgul.cpuinfo.shared.cpu_current_frequency
|
||||
import com.kgurgul.cpuinfo.shared.cpu_frequency_stopped
|
||||
import com.kgurgul.cpuinfo.shared.cpu_has_neon
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l1d
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l1i
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l2
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l3
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l4
|
||||
import com.kgurgul.cpuinfo.shared.cpu_soc_name
|
||||
import com.kgurgul.cpuinfo.shared.no
|
||||
import com.kgurgul.cpuinfo.shared.yes
|
||||
import com.kgurgul.cpuinfo.ui.components.CpuDivider
|
||||
import com.kgurgul.cpuinfo.ui.components.CpuProgressBar
|
||||
import com.kgurgul.cpuinfo.ui.components.CpuPullToRefreshBox
|
||||
import com.kgurgul.cpuinfo.ui.components.ItemValueRow
|
||||
import com.kgurgul.cpuinfo.ui.components.VerticalScrollbar
|
||||
import com.kgurgul.cpuinfo.ui.theme.CpuInfoTheme
|
||||
import com.kgurgul.cpuinfo.ui.theme.spacingSmall
|
||||
@@ -78,95 +70,19 @@ fun CpuInfoScreen(uiState: CpuInfoViewModel.UiState) {
|
||||
modifier = Modifier.fillMaxSize().testTag(CpuInfoScreenTestTags.LAZY_COLUMN),
|
||||
) {
|
||||
uiState.cpuData?.let { cpuData ->
|
||||
item(key = "__soc_name") {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_soc_name),
|
||||
value = cpuData.processorName,
|
||||
modifier = Modifier.testTag(CpuInfoScreenTestTags.SOCKET_NAME),
|
||||
itemsIndexed(
|
||||
cpuData.cpuItems,
|
||||
key = { _, item -> item.getKey() },
|
||||
) { index, itemValue ->
|
||||
InformationRow(
|
||||
title = itemValue.getName(),
|
||||
value = itemValue.getValue(),
|
||||
isLastItem = index == cpuData.cpuItems.lastIndex
|
||||
&& cpuData.frequencies.isEmpty(),
|
||||
)
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
CpuDivider()
|
||||
}
|
||||
item(key = "__abi") {
|
||||
ItemValueRow(title = stringResource(Res.string.cpu_abi), value = cpuData.abi)
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
CpuDivider()
|
||||
}
|
||||
item(key = "__cores") {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_cores),
|
||||
value = cpuData.coreNumber.toString(),
|
||||
)
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
CpuDivider()
|
||||
}
|
||||
item(key = "__has_neon") {
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_has_neon),
|
||||
value =
|
||||
if (cpuData.hasArmNeon) {
|
||||
stringResource(Res.string.yes)
|
||||
} else {
|
||||
stringResource(Res.string.no)
|
||||
},
|
||||
)
|
||||
}
|
||||
if (cpuData.l1dCaches.isNotEmpty()) {
|
||||
item(key = "__l1d") {
|
||||
CpuDivider()
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l1d),
|
||||
value = cpuData.l1dCaches,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l1iCaches.isNotEmpty()) {
|
||||
item(key = "__l1i") {
|
||||
CpuDivider()
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l1i),
|
||||
value = cpuData.l1iCaches,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l2Caches.isNotEmpty()) {
|
||||
item(key = "__l2") {
|
||||
CpuDivider()
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l2),
|
||||
value = cpuData.l2Caches,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l3Caches.isNotEmpty()) {
|
||||
item(key = "__l3") {
|
||||
CpuDivider()
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l3),
|
||||
value = cpuData.l3Caches,
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l4Caches.isNotEmpty()) {
|
||||
item(key = "__l4") {
|
||||
CpuDivider()
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
ItemValueRow(
|
||||
title = stringResource(Res.string.cpu_l4),
|
||||
value = cpuData.l4Caches,
|
||||
)
|
||||
}
|
||||
}
|
||||
cpuData.frequencies.forEachIndexed { i, frequency ->
|
||||
item(key = "__frequency_$i") {
|
||||
if (i == 0) {
|
||||
CpuDivider()
|
||||
Spacer(modifier = Modifier.requiredSize(spacingSmall))
|
||||
}
|
||||
FrequencyItem(index = i, frequency = frequency)
|
||||
}
|
||||
}
|
||||
@@ -222,16 +138,12 @@ fun CpuInfoScreenPreview() {
|
||||
CpuInfoViewModel.UiState(
|
||||
cpuData =
|
||||
CpuData(
|
||||
processorName = "processorName",
|
||||
abi = "abi",
|
||||
coreNumber = 1,
|
||||
hasArmNeon = true,
|
||||
cpuItems = listOf(
|
||||
ItemValue.NameResource(Res.string.cpu_soc_name, "processorName"),
|
||||
ItemValue.Text("ABI", "abi"),
|
||||
ItemValue.Text("Cores", "1"),
|
||||
),
|
||||
frequencies = listOf(CpuData.Frequency(min = 1, max = 2, current = 3)),
|
||||
l1dCaches = "l1dCaches",
|
||||
l1iCaches = "l1iCaches",
|
||||
l2Caches = "l2Caches",
|
||||
l3Caches = "l3Caches",
|
||||
l4Caches = "l4Caches",
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -30,6 +30,9 @@ import com.kgurgul.cpuinfo.domain.model.TextResource
|
||||
import com.kgurgul.cpuinfo.shared.Res
|
||||
import com.kgurgul.cpuinfo.shared.baseline_folder_special_24
|
||||
import com.kgurgul.cpuinfo.shared.cpu
|
||||
import com.kgurgul.cpuinfo.shared.cpu_abi
|
||||
import com.kgurgul.cpuinfo.shared.cpu_cores
|
||||
import com.kgurgul.cpuinfo.shared.cpu_soc_name
|
||||
import com.kgurgul.cpuinfo.shared.ic_cpu_temp
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
|
||||
@@ -106,16 +109,12 @@ object TestData {
|
||||
|
||||
val cpuData =
|
||||
CpuData(
|
||||
processorName = "CPU_NAME",
|
||||
abi = "x64",
|
||||
coreNumber = 1,
|
||||
hasArmNeon = true,
|
||||
cpuItems = listOf(
|
||||
ItemValue.NameResource(Res.string.cpu_soc_name, "CPU_NAME"),
|
||||
ItemValue.NameResource(Res.string.cpu_abi, "x64"),
|
||||
ItemValue.NameResource(Res.string.cpu_cores, "1"),
|
||||
),
|
||||
frequencies = emptyList(),
|
||||
l1dCaches = "",
|
||||
l1iCaches = "",
|
||||
l2Caches = "",
|
||||
l3Caches = "",
|
||||
l4Caches = "",
|
||||
)
|
||||
|
||||
val ramData =
|
||||
|
||||
-4
@@ -23,10 +23,6 @@ class FakeCpuDataNativeProvider : ICpuDataNativeProvider {
|
||||
return "CPU_NAME"
|
||||
}
|
||||
|
||||
override fun hasArmNeon(): Boolean {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun getL1dCaches(): IntArray? {
|
||||
return null
|
||||
}
|
||||
|
||||
-4
@@ -30,10 +30,6 @@ actual class CpuDataNativeProvider actual constructor() : ICpuDataNativeProvider
|
||||
return processor.processorIdentifier.name
|
||||
}
|
||||
|
||||
actual override fun hasArmNeon(): Boolean {
|
||||
return processor.featureFlags.contains("neon")
|
||||
}
|
||||
|
||||
actual override fun getL1dCaches(): IntArray? {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -31,11 +31,7 @@ class CpuInfoScreenTest {
|
||||
@Test
|
||||
fun hasItems() = runComposeUiTest {
|
||||
setContent { CpuInfoScreen(uiState = CpuInfoViewModel.UiState(cpuData = TestData.cpuData)) }
|
||||
listOf(
|
||||
TestData.cpuData.processorName,
|
||||
TestData.cpuData.abi,
|
||||
TestData.cpuData.coreNumber.toString(),
|
||||
)
|
||||
.forEach { tag -> onNodeWithText(tag).performScrollTo().assertIsDisplayed() }
|
||||
listOf("CPU_NAME", "x64", "1")
|
||||
.forEach { text -> onNodeWithText(text).performScrollTo().assertIsDisplayed() }
|
||||
}
|
||||
}
|
||||
|
||||
-8
@@ -31,7 +31,6 @@ import libcpuinfo.cpuinfo_get_l3_caches_count
|
||||
import libcpuinfo.cpuinfo_get_l4_caches
|
||||
import libcpuinfo.cpuinfo_get_l4_caches_count
|
||||
import libcpuinfo.cpuinfo_get_package
|
||||
import libcpuinfo.cpuinfo_has_arm_neon
|
||||
import libcpuinfo.cpuinfo_initialize
|
||||
|
||||
actual class CpuDataNativeProvider actual constructor() : ICpuDataNativeProvider {
|
||||
@@ -50,13 +49,6 @@ actual class CpuDataNativeProvider actual constructor() : ICpuDataNativeProvider
|
||||
}
|
||||
}
|
||||
|
||||
actual override fun hasArmNeon(): Boolean {
|
||||
if (!cpuinfo_initialize()) {
|
||||
return false
|
||||
}
|
||||
return cpuinfo_has_arm_neon()
|
||||
}
|
||||
|
||||
actual override fun getL1dCaches(): IntArray? {
|
||||
if (!cpuinfo_initialize() || cpuinfo_get_l1d_caches_count() == 0.toUInt()) {
|
||||
return null
|
||||
|
||||
-4
@@ -23,10 +23,6 @@ actual class CpuDataNativeProvider actual constructor() : ICpuDataNativeProvider
|
||||
return "Unknown"
|
||||
}
|
||||
|
||||
actual override fun hasArmNeon(): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
actual override fun getL1dCaches(): IntArray? {
|
||||
return null
|
||||
}
|
||||
|
||||
+10
-77
@@ -20,6 +20,7 @@ package com.kgurgul.cpuinfo.wear.features.information.cpu
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.wear.compose.foundation.lazy.items
|
||||
import androidx.wear.compose.material.MaterialTheme
|
||||
import androidx.wear.compose.material.Text
|
||||
import com.google.android.horologist.annotations.ExperimentalHorologistApi
|
||||
@@ -30,22 +31,14 @@ import com.google.android.horologist.compose.layout.rememberResponsiveColumnStat
|
||||
import com.google.android.horologist.compose.material.ListHeaderDefaults.firstItemPadding
|
||||
import com.google.android.horologist.compose.material.ResponsiveListHeader
|
||||
import com.kgurgul.cpuinfo.domain.model.CpuData
|
||||
import com.kgurgul.cpuinfo.domain.model.getKey
|
||||
import com.kgurgul.cpuinfo.domain.model.getName
|
||||
import com.kgurgul.cpuinfo.domain.model.getValue
|
||||
import com.kgurgul.cpuinfo.features.information.cpu.CpuInfoViewModel
|
||||
import com.kgurgul.cpuinfo.shared.Res
|
||||
import com.kgurgul.cpuinfo.shared.cpu
|
||||
import com.kgurgul.cpuinfo.shared.cpu_abi
|
||||
import com.kgurgul.cpuinfo.shared.cpu_cores
|
||||
import com.kgurgul.cpuinfo.shared.cpu_current_frequency
|
||||
import com.kgurgul.cpuinfo.shared.cpu_frequency_stopped
|
||||
import com.kgurgul.cpuinfo.shared.cpu_has_neon
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l1d
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l1i
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l2
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l3
|
||||
import com.kgurgul.cpuinfo.shared.cpu_l4
|
||||
import com.kgurgul.cpuinfo.shared.cpu_soc_name
|
||||
import com.kgurgul.cpuinfo.shared.no
|
||||
import com.kgurgul.cpuinfo.shared.yes
|
||||
import com.kgurgul.cpuinfo.ui.components.CpuProgressBar
|
||||
import com.kgurgul.cpuinfo.utils.formatHz
|
||||
import com.kgurgul.cpuinfo.wear.ui.components.WearCpuChip
|
||||
@@ -82,75 +75,15 @@ fun WearCpuInfoScreen(uiState: CpuInfoViewModel.UiState) {
|
||||
cpuData.frequencies.forEachIndexed { i, frequency ->
|
||||
item(key = "__frequency_$i") { FrequencyItem(index = i, frequency = frequency) }
|
||||
}
|
||||
item(key = "__soc_name") {
|
||||
items(
|
||||
cpuData.cpuItems,
|
||||
key = { it.getKey() },
|
||||
) { itemValue ->
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_soc_name),
|
||||
secondaryLabel = cpuData.processorName,
|
||||
label = itemValue.getName(),
|
||||
secondaryLabel = itemValue.getValue().replace("\n", ", "),
|
||||
)
|
||||
}
|
||||
item(key = "__abi") {
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_abi),
|
||||
secondaryLabel = cpuData.abi,
|
||||
)
|
||||
}
|
||||
item(key = "__cores") {
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_cores),
|
||||
secondaryLabel = cpuData.coreNumber.toString(),
|
||||
)
|
||||
}
|
||||
item(key = "__has_neon") {
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_has_neon),
|
||||
secondaryLabel =
|
||||
if (cpuData.hasArmNeon) {
|
||||
stringResource(Res.string.yes)
|
||||
} else {
|
||||
stringResource(Res.string.no)
|
||||
},
|
||||
)
|
||||
}
|
||||
if (cpuData.l1dCaches.isNotEmpty()) {
|
||||
item(key = "__l1d") {
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_l1d),
|
||||
secondaryLabel = cpuData.l1dCaches.replace("\n", ", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l1iCaches.isNotEmpty()) {
|
||||
item(key = "__l1i") {
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_l1i),
|
||||
secondaryLabel = cpuData.l1iCaches.replace("\n", ", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l2Caches.isNotEmpty()) {
|
||||
item(key = "__l2") {
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_l2),
|
||||
secondaryLabel = cpuData.l2Caches.replace("\n", ", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l3Caches.isNotEmpty()) {
|
||||
item(key = "__l3") {
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_l3),
|
||||
secondaryLabel = cpuData.l3Caches.replace("\n", ", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
if (cpuData.l4Caches.isNotEmpty()) {
|
||||
item(key = "__l4") {
|
||||
WearCpuChip(
|
||||
label = stringResource(Res.string.cpu_l4),
|
||||
secondaryLabel = cpuData.l4Caches.replace("\n", ", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user