Skip to content

Commit 1cbbba4

Browse files
committed
fixed slot ViewModel on init_boot devices
bumped dependencies
1 parent fe6187c commit 1cbbba4

File tree

7 files changed

+33
-21
lines changed

7 files changed

+33
-21
lines changed

app/build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId "com.github.capntrips.kernelflasher"
1313
minSdk 29
1414
targetSdk 34
15-
versionCode 18
16-
versionName "1.0.0-alpha18"
15+
versionCode 19
16+
versionName "1.0.0-alpha19"
1717

1818
javaCompileOptions {
1919
annotationProcessorOptions {
@@ -24,6 +24,7 @@ android {
2424
}
2525
}
2626
ndk {
27+
//noinspection ChromeOsAbiSupport
2728
abiFilters = ['armeabi-v7a', 'arm64-v8a']
2829
}
2930
vectorDrawables {
@@ -60,6 +61,9 @@ android {
6061
resources {
6162
excludes += '/META-INF/{AL2.0,LGPL2.1}'
6263
}
64+
jniLibs {
65+
useLegacyPackaging true
66+
}
6367
}
6468
namespace 'com.github.capntrips.kernelflasher'
6569
}

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<application
88
android:allowBackup="true"
99
android:dataExtractionRules="@xml/data_extraction_rules"
10-
android:extractNativeLibs="true"
1110
android:fullBackupContent="@xml/backup_rules"
1211
android:icon="@mipmap/ic_launcher"
1312
android:label="@string/app_name"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ import androidx.compose.ui.unit.dp
3838
import androidx.navigation.NavController
3939
import com.github.capntrips.kernelflasher.R
4040
import com.github.capntrips.kernelflasher.ui.screens.main.MainViewModel
41+
import kotlinx.serialization.ExperimentalSerializationApi
4142

4243
@ExperimentalMaterialApi
4344
@ExperimentalMaterial3Api
45+
@ExperimentalSerializationApi
4446
@Composable
4547
fun RefreshableScreen(
4648
viewModel: MainViewModel,

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,12 @@ import com.topjohnwu.superuser.nio.FileSystemManager
2020
import kotlinx.coroutines.Dispatchers
2121
import kotlinx.coroutines.launch
2222
import kotlinx.coroutines.withContext
23+
import kotlinx.serialization.ExperimentalSerializationApi
2324
import java.io.File
2425
import java.time.LocalDateTime
2526
import java.time.format.DateTimeFormatter
2627

28+
@ExperimentalSerializationApi
2729
class MainViewModel(
2830
context: Context,
2931
fileSystemManager: FileSystemManager,
@@ -55,19 +57,20 @@ class MainViewModel(
5557

5658
init {
5759
PartitionUtil.init(context, fileSystemManager)
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")!!
60+
val bootA = PartitionUtil.findPartitionBlockDevice(context, "boot", "_a")!!
61+
val bootB = PartitionUtil.findPartitionBlockDevice(context, "boot", "_b")!!
62+
val initBootA = PartitionUtil.findPartitionBlockDevice(context, "init_boot", "_a")
63+
val initBootB = PartitionUtil.findPartitionBlockDevice(context, "init_boot", "_b")
6164
kernelVersion = Shell.cmd("echo $(uname -r) $(uname -v)").exec().out[0]
6265
slotSuffix = Shell.cmd("getprop ro.boot.slot_suffix").exec().out[0]
6366
backups = BackupsViewModel(context, fileSystemManager, navController, _isRefreshing, _backups)
6467
updates = UpdatesViewModel(context, fileSystemManager, navController, _isRefreshing)
6568
reboot = RebootViewModel(context, fileSystemManager, navController, _isRefreshing)
66-
slotA = SlotViewModel(context, fileSystemManager, navController, _isRefreshing, slotSuffix == "_a", "_a", bootA, _backups)
69+
slotA = SlotViewModel(context, fileSystemManager, navController, _isRefreshing, slotSuffix == "_a", "_a", bootA, initBootA, _backups)
6770
if (slotA.hasError) {
6871
_error = slotA.error
6972
}
70-
slotB = SlotViewModel(context, fileSystemManager, navController, _isRefreshing, slotSuffix == "_b", "_b", bootB, _backups)
73+
slotB = SlotViewModel(context, fileSystemManager, navController, _isRefreshing, slotSuffix == "_b", "_b", bootB, initBootB, _backups)
7174
if (slotB.hasError) {
7275
_error = slotB.error
7376
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SlotViewModel(
4444
val isActive: Boolean,
4545
val slotSuffix: String,
4646
private val boot: File,
47+
private val initBoot: File?,
4748
private val _backups: MutableMap<String, Backup>
4849
) : ViewModel() {
4950
companion object {
@@ -89,6 +90,9 @@ class SlotViewModel(
8990
fun refresh(context: Context) {
9091
val magiskboot = File(context.filesDir, "magiskboot")
9192
Shell.cmd("$magiskboot unpack $boot").exec()
93+
if (initBoot != null) {
94+
Shell.cmd("$magiskboot unpack $initBoot").exec()
95+
}
9296

9397
val ramdisk = File(context.filesDir, "ramdisk.cpio")
9498
val kernel = File(context.filesDir, "kernel")
@@ -234,6 +238,9 @@ class SlotViewModel(
234238
private fun _getKernel(context: Context) {
235239
val magiskboot = File(context.filesDir, "magiskboot")
236240
Shell.cmd("$magiskboot unpack $boot").exec()
241+
if (initBoot != null) {
242+
Shell.cmd("$magiskboot unpack $initBoot").exec()
243+
}
237244
val kernel = File(context.filesDir, "kernel")
238245
if (kernel.exists()) {
239246
val result = Shell.cmd("strings kernel | grep -E -m1 'Linux version.*#' | cut -d\\ -f3-").exec().out

gradle/libs.versions.toml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
11
[versions]
2-
kotlin = "1.9.10"
3-
compose-compiler = "1.5.3"
2+
kotlin = "1.9.21"
3+
compose-compiler = "1.5.6"
44

5-
androidx-activity-compose = "1.7.2"
5+
androidx-activity-compose = "1.8.2"
66
androidx-appcompat = "1.6.1"
7-
androidx-compose = "1.5.2"
7+
androidx-compose = "1.5.4"
88
androidx-compose-material3 = "1.1.2"
99
androidx-core-ktx = "1.12.0"
1010
androidx-core-splashscreen = "1.0.1"
11-
androidx-fragment = "1.6.1"
1211
androidx-lifecycle = "2.6.2"
13-
androidx-navigation-compose = "2.7.3"
14-
androidx-room = "2.5.2"
12+
androidx-navigation-compose = "2.7.6"
13+
androidx-room = "2.6.1"
1514
kotlinx-serialization-json = "1.5.1"
1615
libsu = "5.2.1"
17-
material = "1.9.0"
16+
material = "1.11.0"
1817
okhttp = "4.11.0"
1918

20-
android-application = "8.1.2"
21-
devtools-ksp = "1.9.10-1.0.13"
19+
android-application = "8.2.0"
20+
devtools-ksp = "1.9.21-1.0.16"
2221

2322
[libraries]
24-
compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compose-compiler" }
25-
2623
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidx-activity-compose" }
2724
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
2825
androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation", version.ref = "androidx-compose" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Fri Apr 14 13:36:42 CDT 2023
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)