Skip to content

Commit 13ccf53

Browse files
committed
fixed init_boot devices
added tap to expand for long strings bumped dependencies minor bugfixes
1 parent 80d66f4 commit 13ccf53

File tree

11 files changed

+48
-33
lines changed

11 files changed

+48
-33
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId "com.github.capntrips.kernelflasher"
1313
minSdk 30
1414
targetSdk 33
15-
versionCode 11
16-
versionName "1.0.0-alpha11"
15+
versionCode 12
16+
versionName "1.0.0-alpha12"
1717

1818
vectorDrawables {
1919
useSupportLibrary true

app/src/main/assets/lptools_static

100644100755
21.4 KB
Binary file not shown.

app/src/main/java/com/github/capntrips/kernelflasher/ui/components/DataRow.kt

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.capntrips.kernelflasher.ui.components
22

3+
import androidx.compose.foundation.clickable
34
import androidx.compose.foundation.layout.Row
45
import androidx.compose.foundation.layout.Spacer
56
import androidx.compose.foundation.layout.width
@@ -9,6 +10,8 @@ import androidx.compose.material3.Text
910
import androidx.compose.runtime.Composable
1011
import androidx.compose.runtime.MutableState
1112
import androidx.compose.runtime.getValue
13+
import androidx.compose.runtime.mutableStateOf
14+
import androidx.compose.runtime.remember
1215
import androidx.compose.runtime.setValue
1316
import androidx.compose.ui.Modifier
1417
import androidx.compose.ui.graphics.Color
@@ -25,7 +28,8 @@ fun DataRow(
2528
labelStyle: TextStyle = MaterialTheme.typography.labelMedium,
2629
valueColor: Color = Color.Unspecified,
2730
valueStyle: TextStyle = MaterialTheme.typography.titleSmall,
28-
mutableMaxWidth: MutableState<Int>? = null
31+
mutableMaxWidth: MutableState<Int>? = null,
32+
clickable: Boolean = false,
2933
) {
3034
Row {
3135
val modifier = if (mutableMaxWidth != null) {
@@ -51,13 +55,22 @@ fun DataRow(
5155
)
5256
Spacer(Modifier.width(8.dp))
5357
SelectionContainer(Modifier.alignByBaseline()) {
58+
var clicked by remember { mutableStateOf(false)}
59+
val modifier = if (clickable) {
60+
Modifier
61+
.clickable { clicked = !clicked }
62+
.alignByBaseline()
63+
} else {
64+
Modifier
65+
.alignByBaseline()
66+
}
5467
Text(
55-
modifier = Modifier.alignByBaseline(),
68+
modifier = modifier,
5669
text = value,
5770
color = valueColor,
5871
style = valueStyle,
59-
maxLines = 1,
60-
overflow = TextOverflow.Ellipsis
72+
maxLines = if (clicked) Int.MAX_VALUE else 1,
73+
overflow = if (clicked) TextOverflow.Visible else TextOverflow.Ellipsis
6174
)
6275
}
6376
}

app/src/main/java/com/github/capntrips/kernelflasher/ui/components/SlotCard.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ fun SlotCard(
4848
DataRow(
4949
label = stringResource(R.string.kernel_version),
5050
value = if (viewModel.kernelVersion != null) viewModel.kernelVersion!! else "",
51-
mutableMaxWidth = cardWidth
51+
mutableMaxWidth = cardWidth,
52+
clickable = true
5253
)
5354
}
5455
if (showDlkm && viewModel.hasVendorDlkm) {

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/backups/BackupsContent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fun ColumnScope.BackupsContent(
4242
val cardWidth = remember { mutableStateOf(0) }
4343
val currentBackup = viewModel.backups.getValue(viewModel.currentBackup!!)
4444
DataRow(stringResource(R.string.backup_type), currentBackup.type, mutableMaxWidth = cardWidth)
45-
DataRow(stringResource(R.string.kernel_version), currentBackup.kernelVersion, mutableMaxWidth = cardWidth)
45+
DataRow(stringResource(R.string.kernel_version), currentBackup.kernelVersion, mutableMaxWidth = cardWidth, clickable = true)
4646
if (currentBackup.type == "raw") {
4747
DataRow(
4848
label = stringResource(R.string.boot_sha1),
@@ -130,7 +130,7 @@ fun ColumnScope.BackupsContent(
130130
mutableMaxWidth = cardWidth
131131
)
132132
}
133-
DataRow(stringResource(R.string.kernel_version), currentBackup.kernelVersion, mutableMaxWidth = cardWidth)
133+
DataRow(stringResource(R.string.kernel_version), currentBackup.kernelVersion, mutableMaxWidth = cardWidth, clickable = true)
134134
}
135135
}
136136
} else {

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/backups/SlotBackupsContent.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,15 @@ fun ColumnScope.SlotBackupsContent(
5757
viewModel = slotViewModel,
5858
navController = navController,
5959
isSlotScreen = true,
60+
showDlkm = false,
6061
)
6162
Spacer(Modifier.height(16.dp))
6263
if (backupsViewModel.currentBackup != null && backupsViewModel.backups.containsKey(backupsViewModel.currentBackup)) {
6364
val currentBackup = backupsViewModel.backups.getValue(backupsViewModel.currentBackup!!)
64-
DataCard (backupsViewModel.currentBackup!!) {
65+
DataCard(backupsViewModel.currentBackup!!) {
6566
val cardWidth = remember { mutableStateOf(0) }
6667
DataRow(stringResource(R.string.backup_type), currentBackup.type, mutableMaxWidth = cardWidth)
67-
DataRow(stringResource(R.string.kernel_version), currentBackup.kernelVersion, mutableMaxWidth = cardWidth)
68+
DataRow(stringResource(R.string.kernel_version), currentBackup.kernelVersion, mutableMaxWidth = cardWidth, clickable = true)
6869
if (currentBackup.type == "raw") {
6970
DataRow(
7071
label = stringResource(R.string.boot_sha1),
@@ -153,7 +154,7 @@ fun ColumnScope.SlotBackupsContent(
153154
}
154155
}
155156
) {
156-
DataRow(stringResource(R.string.kernel_version), backups[id]!!.kernelVersion)
157+
DataRow(stringResource(R.string.kernel_version), backups[id]!!.kernelVersion, clickable = true)
157158
}
158159
}
159160
} else {
@@ -208,8 +209,6 @@ fun ColumnScope.SlotBackupsContent(
208209
)
209210
Spacer(Modifier.height(5.dp))
210211
}
211-
// TODO: disable button if no partitions are selected
212-
// TODO: disable button if any partitions are unavailable
213212
OutlinedButton(
214213
modifier = Modifier
215214
.fillMaxWidth(),
@@ -219,7 +218,8 @@ fun ColumnScope.SlotBackupsContent(
219218
navController.navigate("slot$slotSuffix/backups/${backupsViewModel.currentBackup!!}/restore/restore") {
220219
popUpTo("slot{slotSuffix}")
221220
}
222-
}
221+
},
222+
enabled = currentBackup.hashes == null || (PartitionUtil.PartitionNames.none { currentBackup.hashes.get(it) != null && backupsViewModel.backupPartitions[it] == null } && backupsViewModel.backupPartitions.filter { it.value }.isNotEmpty())
223223
) {
224224
Text(stringResource(R.string.restore))
225225
}

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/main/MainContent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fun ColumnScope.MainContent(
3434
val cardWidth = remember { mutableStateOf(0) }
3535
DataRow(stringResource(R.string.model), "${Build.MODEL} (${Build.DEVICE})", mutableMaxWidth = cardWidth)
3636
DataRow(stringResource(R.string.build_number), Build.ID, mutableMaxWidth = cardWidth)
37-
DataRow(stringResource(R.string.kernel_version), System.getProperty("os.version")!!, mutableMaxWidth = cardWidth)
37+
DataRow(stringResource(R.string.kernel_version), viewModel.kernelVersion, mutableMaxWidth = cardWidth, clickable = true)
3838
DataRow(stringResource(R.string.slot_suffix), viewModel.slotSuffix, mutableMaxWidth = cardWidth)
3939
}
4040
Spacer(Modifier.height(16.dp))

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/main/MainViewModel.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class MainViewModel(
3434
}
3535
val slotSuffix: String
3636

37+
val kernelVersion: String
3738
val slotA: SlotViewModel
3839
val slotB: SlotViewModel
3940
val backups: BackupsViewModel
@@ -54,9 +55,10 @@ class MainViewModel(
5455

5556
init {
5657
PartitionUtil.init(context, fileSystemManager)
57-
val bootA = PartitionUtil.findPartitionBlockDevice(context, "boot", "_a")!!
58-
val bootB = PartitionUtil.findPartitionBlockDevice(context, "boot", "_b")!!
59-
58+
val partitionName = if (fileSystemManager.getFile("/dev/block/by-name/init_boot_a").exists()) "init_boot" else "boot"
59+
val bootA = PartitionUtil.findPartitionBlockDevice(context, partitionName, "_a")!!
60+
val bootB = PartitionUtil.findPartitionBlockDevice(context, partitionName, "_b")!!
61+
kernelVersion = Shell.cmd("echo $(uname -r) $(uname -v)").exec().out[0]
6062
slotSuffix = Shell.cmd("getprop ro.boot.slot_suffix").exec().out[0]
6163
backups = BackupsViewModel(context, fileSystemManager, navController, _isRefreshing, _backups)
6264
updates = UpdatesViewModel(context, fileSystemManager, navController, _isRefreshing)

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotFlashContent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ fun ColumnScope.SlotFlashContent(
109109
}
110110
}
111111
}
112-
// TODO: disable button if no partitions are selected
113112
OutlinedButton(
114113
modifier = Modifier
115114
.fillMaxWidth(),
@@ -119,7 +118,8 @@ fun ColumnScope.SlotFlashContent(
119118
navController.navigate("slot$slotSuffix/backup/backup") {
120119
popUpTo("slot{slotSuffix}")
121120
}
122-
}
121+
},
122+
enabled = viewModel.backupPartitions.filter { it.value }.isNotEmpty()
123123
) {
124124
Text(stringResource(R.string.backup))
125125
}

app/src/main/java/com/github/capntrips/kernelflasher/ui/screens/slot/SlotViewModel.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ class SlotViewModel(
241241
Shell.cmd("/data/adb/magisk/magiskboot unpack $boot").exec()
242242
val kernel = File(context.filesDir, "kernel")
243243
if (kernel.exists()) {
244-
val result = Shell.cmd("strings kernel | grep -E -m1 'Linux version.*#' | cut -d\\ -f3").exec().out
244+
val result = Shell.cmd("strings kernel | grep -E -m1 'Linux version.*#' | cut -d\\ -f3-").exec().out
245245
if (result.isNotEmpty()) {
246-
kernelVersion = result[0]
246+
kernelVersion = result[0].replace("""\(.+\)""".toRegex(), "").replace("""\s+""".toRegex(), " ")
247247
}
248248
}
249249
Shell.cmd("/data/adb/magisk/magiskboot cleanup").exec()
@@ -259,7 +259,7 @@ class SlotViewModel(
259259
@Suppress("LiftReturnOrAssignment")
260260
if (partition.exists()) {
261261
val dmPath = Shell.cmd("readlink -f $partition").exec().out[0]
262-
val mounts = Shell.cmd("mount | grep $dmPath").exec().out
262+
val mounts = Shell.cmd("mount | grep -w $dmPath").exec().out
263263
return mounts.isNotEmpty()
264264
} else {
265265
return false

0 commit comments

Comments
 (0)