Skip to content
This repository has been archived by the owner on Jul 7, 2024. It is now read-only.

Commit

Permalink
Fix resource aligning on Android 11 (Also log install errors)
Browse files Browse the repository at this point in the history
  • Loading branch information
wingio committed Sep 28, 2023
1 parent d969875 commit 1de8690
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ android {
applicationId = "dev.beefers.vendetta.manager"
minSdk = 28
targetSdk = 34
versionCode = 1091
versionName = "1.0.91"
versionCode = 1092
versionName = "1.0.92"

buildConfigField("String", "GIT_BRANCH", "\"${getCurrentBranch()}\"")
buildConfigField("String", "GIT_COMMIT", "\"${getLatestCommit()}\"")
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
android:name=".ui.activity.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Manager.Splash">
android:theme="@style/Theme.Manager.Splash"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Intent
import android.content.pm.PackageInstaller
import android.os.IBinder
import dev.beefers.vendetta.manager.R
import dev.beefers.vendetta.manager.ui.activity.MainActivity
import dev.beefers.vendetta.manager.utils.showToast

class InstallService : Service() {
Expand Down Expand Up @@ -35,7 +36,18 @@ class InstallService : Service() {
PackageInstaller.STATUS_FAILURE_ABORTED -> if (isInstall) showToast(R.string.installer_aborted)

else -> {
if (isInstall) messages[statusCode]?.let(::showToast)
if (isInstall) {
messages[statusCode]?.let(::showToast)

// Send error messages back to the activity for debugging (to be received by InstallerScreen)
startActivity(
Intent("vendetta.actions.ACTION_INSTALL_FINISHED").apply {
setClass(this@InstallService, MainActivity::class.java)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
putExtra("vendetta.extras.EXTRA_MESSAGE", intent.getStringExtra(PackageInstaller.EXTRA_STATUS_MESSAGE))
}
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package dev.beefers.vendetta.manager.ui.screen.installer

import android.content.Intent
import androidx.activity.ComponentActivity
import androidx.activity.compose.BackHandler
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
Expand All @@ -21,14 +23,17 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp
import androidx.core.util.Consumer
import cafe.adriel.voyager.core.screen.Screen
import cafe.adriel.voyager.koin.getScreenModel
import cafe.adriel.voyager.navigator.LocalNavigator
Expand All @@ -48,6 +53,7 @@ class InstallerScreen(
@Composable
override fun Content() {
val nav = LocalNavigator.currentOrThrow
val activity = LocalContext.current as? ComponentActivity
val viewModel: InstallerViewModel = getScreenModel {
parametersOf(version)
}
Expand All @@ -60,6 +66,21 @@ class InstallerScreen(
expandedGroup = viewModel.currentStep?.group
}

// Listen for error messages from InstallService
val intentListener: (Intent) -> Unit = remember {
{
val msg = it.getStringExtra("vendetta.extras.EXTRA_MESSAGE")
viewModel.addLogError(msg ?: "")
}
}

DisposableEffect(Unit) {
activity?.addOnNewIntentListener(intentListener)
onDispose {
activity?.removeOnNewIntentListener(intentListener)
}
}

BackHandler(
enabled = !viewModel.isFinished
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class InstallerViewModel(
}
}

fun addLogError(msg: String) = logger.e("\n$msg")

fun copyDebugInfo() {
context.copyText(debugInfo)
}
Expand Down Expand Up @@ -348,7 +350,7 @@ class InstallerViewModel(
logger.i("Creating dir for signed apks")
signedDir.mkdir()
val apks = arrayOf(baseApk, libsApk, langApk, resApk)
if (Build.VERSION.SDK_INT >= 31) {
if (Build.VERSION.SDK_INT >= 30) {
for (file in apks) {
logger.i("Byte aligning ${file!!.name}")
val bytes = ZipReader(file).use {
Expand Down

0 comments on commit 1de8690

Please sign in to comment.