Skip to content

Commit

Permalink
fixed slot ViewModel on init_boot devices
Browse files Browse the repository at this point in the history
bumped dependencies
  • Loading branch information
capntrips committed Dec 17, 2023
1 parent fe6187c commit 1cbbba4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 21 deletions.
8 changes: 6 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId "com.github.capntrips.kernelflasher"
minSdk 29
targetSdk 34
versionCode 18
versionName "1.0.0-alpha18"
versionCode 19
versionName "1.0.0-alpha19"

javaCompileOptions {
annotationProcessorOptions {
Expand All @@ -24,6 +24,7 @@ android {
}
}
ndk {
//noinspection ChromeOsAbiSupport
abiFilters = ['armeabi-v7a', 'arm64-v8a']
}
vectorDrawables {
Expand Down Expand Up @@ -60,6 +61,9 @@ android {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
jniLibs {
useLegacyPackaging true
}
}
namespace 'com.github.capntrips.kernelflasher'
}
Expand Down
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:extractNativeLibs="true"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ import androidx.compose.ui.unit.dp
import androidx.navigation.NavController
import com.github.capntrips.kernelflasher.R
import com.github.capntrips.kernelflasher.ui.screens.main.MainViewModel
import kotlinx.serialization.ExperimentalSerializationApi

@ExperimentalMaterialApi
@ExperimentalMaterial3Api
@ExperimentalSerializationApi
@Composable
fun RefreshableScreen(
viewModel: MainViewModel,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ import com.topjohnwu.superuser.nio.FileSystemManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import kotlinx.serialization.ExperimentalSerializationApi
import java.io.File
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter

@ExperimentalSerializationApi
class MainViewModel(
context: Context,
fileSystemManager: FileSystemManager,
Expand Down Expand Up @@ -55,19 +57,20 @@ class MainViewModel(

init {
PartitionUtil.init(context, fileSystemManager)
val partitionName = if (fileSystemManager.getFile("/dev/block/by-name/init_boot_a").exists()) "init_boot" else "boot"
val bootA = PartitionUtil.findPartitionBlockDevice(context, partitionName, "_a")!!
val bootB = PartitionUtil.findPartitionBlockDevice(context, partitionName, "_b")!!
val bootA = PartitionUtil.findPartitionBlockDevice(context, "boot", "_a")!!
val bootB = PartitionUtil.findPartitionBlockDevice(context, "boot", "_b")!!
val initBootA = PartitionUtil.findPartitionBlockDevice(context, "init_boot", "_a")
val initBootB = PartitionUtil.findPartitionBlockDevice(context, "init_boot", "_b")
kernelVersion = Shell.cmd("echo $(uname -r) $(uname -v)").exec().out[0]
slotSuffix = Shell.cmd("getprop ro.boot.slot_suffix").exec().out[0]
backups = BackupsViewModel(context, fileSystemManager, navController, _isRefreshing, _backups)
updates = UpdatesViewModel(context, fileSystemManager, navController, _isRefreshing)
reboot = RebootViewModel(context, fileSystemManager, navController, _isRefreshing)
slotA = SlotViewModel(context, fileSystemManager, navController, _isRefreshing, slotSuffix == "_a", "_a", bootA, _backups)
slotA = SlotViewModel(context, fileSystemManager, navController, _isRefreshing, slotSuffix == "_a", "_a", bootA, initBootA, _backups)
if (slotA.hasError) {
_error = slotA.error
}
slotB = SlotViewModel(context, fileSystemManager, navController, _isRefreshing, slotSuffix == "_b", "_b", bootB, _backups)
slotB = SlotViewModel(context, fileSystemManager, navController, _isRefreshing, slotSuffix == "_b", "_b", bootB, initBootB, _backups)
if (slotB.hasError) {
_error = slotB.error
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class SlotViewModel(
val isActive: Boolean,
val slotSuffix: String,
private val boot: File,
private val initBoot: File?,
private val _backups: MutableMap<String, Backup>
) : ViewModel() {
companion object {
Expand Down Expand Up @@ -89,6 +90,9 @@ class SlotViewModel(
fun refresh(context: Context) {
val magiskboot = File(context.filesDir, "magiskboot")
Shell.cmd("$magiskboot unpack $boot").exec()
if (initBoot != null) {
Shell.cmd("$magiskboot unpack $initBoot").exec()
}

val ramdisk = File(context.filesDir, "ramdisk.cpio")
val kernel = File(context.filesDir, "kernel")
Expand Down Expand Up @@ -234,6 +238,9 @@ class SlotViewModel(
private fun _getKernel(context: Context) {
val magiskboot = File(context.filesDir, "magiskboot")
Shell.cmd("$magiskboot unpack $boot").exec()
if (initBoot != null) {
Shell.cmd("$magiskboot unpack $initBoot").exec()
}
val kernel = File(context.filesDir, "kernel")
if (kernel.exists()) {
val result = Shell.cmd("strings kernel | grep -E -m1 'Linux version.*#' | cut -d\\ -f3-").exec().out
Expand Down
21 changes: 9 additions & 12 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
[versions]
kotlin = "1.9.10"
compose-compiler = "1.5.3"
kotlin = "1.9.21"
compose-compiler = "1.5.6"

androidx-activity-compose = "1.7.2"
androidx-activity-compose = "1.8.2"
androidx-appcompat = "1.6.1"
androidx-compose = "1.5.2"
androidx-compose = "1.5.4"
androidx-compose-material3 = "1.1.2"
androidx-core-ktx = "1.12.0"
androidx-core-splashscreen = "1.0.1"
androidx-fragment = "1.6.1"
androidx-lifecycle = "2.6.2"
androidx-navigation-compose = "2.7.3"
androidx-room = "2.5.2"
androidx-navigation-compose = "2.7.6"
androidx-room = "2.6.1"
kotlinx-serialization-json = "1.5.1"
libsu = "5.2.1"
material = "1.9.0"
material = "1.11.0"
okhttp = "4.11.0"

android-application = "8.1.2"
devtools-ksp = "1.9.10-1.0.13"
android-application = "8.2.0"
devtools-ksp = "1.9.21-1.0.16"

[libraries]
compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compose-compiler" }

androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidx-activity-compose" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidx-appcompat" }
androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation", version.ref = "androidx-compose" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Apr 14 13:36:42 CDT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit 1cbbba4

Please sign in to comment.