Skip to content

Commit

Permalink
Merge branch 'main' into ci/github-attest-slsa-l2
Browse files Browse the repository at this point in the history
  • Loading branch information
validcube authored Nov 13, 2024
2 parents 98c4589 + 4c51ad3 commit d9f0da4
Show file tree
Hide file tree
Showing 82 changed files with 607 additions and 574 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:

- name: Setup keystore
run: |
echo "${{ secrets.KEYSTORE }}" | base64 --decode > "keystore.jks"
echo "${{ secrets.KEYSTORE }}" | base64 --decode > "android/app/keystore.jks"
- name: Release
env:
Expand Down
26 changes: 19 additions & 7 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

android {
namespace = "app.revanced.manager.flutter"
compileSdk = 34
compileSdk = 35
ndkVersion = "27.0.12077973"

compileOptions {
Expand All @@ -24,9 +24,19 @@ android {
defaultConfig {
applicationId = "app.revanced.manager.flutter"
minSdk = 26
targetSdk = 34
targetSdk = 35
versionCode = flutter.versionCode
versionName = flutter.versionName

resValue("string", "app_name", "ReVanced Manager")
}

applicationVariants.all {
outputs.all {
this as com.android.build.gradle.internal.api.ApkVariantOutputImpl

outputFileName = "revanced-manager-$versionName.apk"
}
}

buildTypes {
Expand All @@ -37,7 +47,6 @@ android {
signingConfig = signingConfigs["debug"]

ndk.abiFilters += setOf("armeabi-v7a", "arm64-v8a", "x86_64")
setProperty("archivesBaseName", "revanced-manager-v${flutter.versionName}")
}

release {
Expand All @@ -52,19 +61,21 @@ android {
keyAlias = System.getenv("KEYSTORE_ENTRY_ALIAS")
keyPassword = System.getenv("KEYSTORE_ENTRY_PASSWORD")
}

resValue("string", "app_name", "ReVanced Manager")
} else {
resValue("string", "app_name", "ReVanced Manager (Debug)")
applicationIdSuffix = ".debug"

signingConfig = signingConfigs["debug"]
}

resValue("string", "app_name", "ReVanced Manager")
resValue("string", "app_name", "ReVanced Manager (Debug signed)")
}
}

debug {
resValue("string", "app_name", "ReVanced Manager (Debug)")
applicationIdSuffix = ".debug"

resValue("string", "app_name", "ReVanced Manager (Debug)")
}
}

Expand All @@ -80,6 +91,7 @@ android {
}
}


flutter {
source = "../.."
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package app.revanced.manager.flutter
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.os.Bundle
import android.util.Base64
Expand All @@ -17,9 +16,8 @@ import java.security.MessageDigest
class ExportSettingsActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val callingPackageName = getCallingPackage()!!

if (getFingerprint(callingPackageName) == getFingerprint(getPackageName())) {
if (getFingerprint(callingPackage!!) == getFingerprint(packageName)) {
// Create JSON Object
val json = JSONObject()

Expand Down Expand Up @@ -64,7 +62,7 @@ class ExportSettingsActivity : Activity() {
fun getFingerprint(packageName: String): String {
// Get the signature of the app that matches the package name
val packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES)
val signature = packageInfo.signatures[0]
val signature = packageInfo.signatures!![0]

// Get the raw certificate data
val rawCert = signature.toByteArray()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ import android.os.Handler
import android.os.Looper
import app.revanced.library.ApkUtils
import app.revanced.library.ApkUtils.applyTo
import app.revanced.library.installation.installer.LocalInstaller
import app.revanced.manager.flutter.utils.Aapt
import app.revanced.manager.flutter.utils.packageInstaller.InstallerReceiver
import app.revanced.manager.flutter.utils.packageInstaller.UninstallerReceiver
import app.revanced.patcher.PatchBundleLoader
import app.revanced.patcher.PatchSet
import app.revanced.patcher.Patcher
import app.revanced.patcher.PatcherConfig
import app.revanced.patcher.patch.Patch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.loadPatchesFromDex
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel
Expand All @@ -37,7 +38,7 @@ class MainActivity : FlutterActivity() {
private var cancel: Boolean = false
private var stopResult: MethodChannel.Result? = null

private lateinit var patches: PatchSet
private lateinit var patches: Set<Patch<*>>

override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
super.configureFlutterEngine(flutterEngine)
Expand Down Expand Up @@ -70,7 +71,6 @@ class MainActivity : FlutterActivity() {
"runPatcher" -> {
val inFilePath = call.argument<String>("inFilePath")
val outFilePath = call.argument<String>("outFilePath")
val integrationsPath = call.argument<String>("integrationsPath")
val selectedPatches = call.argument<List<String>>("selectedPatches")
val options = call.argument<Map<String, Map<String, Any>>>("options")
val tmpDirPath = call.argument<String>("tmpDirPath")
Expand All @@ -80,7 +80,6 @@ class MainActivity : FlutterActivity() {
if (
inFilePath != null &&
outFilePath != null &&
integrationsPath != null &&
selectedPatches != null &&
options != null &&
tmpDirPath != null &&
Expand All @@ -92,14 +91,17 @@ class MainActivity : FlutterActivity() {
result,
inFilePath,
outFilePath,
integrationsPath,
selectedPatches,
options,
tmpDirPath,
keyStoreFilePath,
keystorePassword
)
} else result.notImplemented()
} else result.error(
"INVALID_ARGUMENTS",
"Invalid arguments",
"One or more arguments are missing"
)
}

"stopPatcher" -> {
Expand All @@ -113,14 +115,16 @@ class MainActivity : FlutterActivity() {
try {
val patchBundleFile = File(patchBundleFilePath)
patchBundleFile.setWritable(false)
patches = PatchBundleLoader.Dex(
patchBundleFile,
patches = loadPatchesFromDex(
setOf(patchBundleFile),
optimizedDexDirectory = codeCacheDir
)
} catch (ex: Exception) {
return@setMethodCallHandler result.notImplemented()
} catch (err: Error) {
return@setMethodCallHandler result.notImplemented()
} catch (t: Throwable) {
return@setMethodCallHandler result.error(
"PATCH_BUNDLE_ERROR",
"Failed to load patch bundle",
t.stackTraceToString()
)
}

JSONArray().apply {
Expand All @@ -130,13 +134,13 @@ class MainActivity : FlutterActivity() {
put("description", it.description)
put("excluded", !it.use)
put("compatiblePackages", JSONArray().apply {
it.compatiblePackages?.forEach { compatiblePackage ->
it.compatiblePackages?.forEach { (name, versions) ->
val compatiblePackageJson = JSONObject().apply {
put("name", compatiblePackage.name)
put("name", name)
put(
"versions",
JSONArray().apply {
compatiblePackage.versions?.forEach { version ->
versions?.forEach { version ->
put(version)
}
})
Expand Down Expand Up @@ -172,7 +176,7 @@ class MainActivity : FlutterActivity() {
}
})
} ?: put("values", null)
put("valueType", option.valueType)
put("type", option.type)
}.let(::put)
}
})
Expand Down Expand Up @@ -211,7 +215,6 @@ class MainActivity : FlutterActivity() {
result: MethodChannel.Result,
inFilePath: String,
outFilePath: String,
integrationsPath: String,
selectedPatches: List<String>,
options: Map<String, Map<String, Any>>,
tmpDirPath: String,
Expand All @@ -223,7 +226,6 @@ class MainActivity : FlutterActivity() {
inFile.setWritable(true)
inFile.setReadable(true)
val outFile = File(outFilePath)
val integrations = File(integrationsPath)
val keyStoreFile = File(keyStoreFilePath)
val tmpDir = File(tmpDirPath)

Expand Down Expand Up @@ -281,16 +283,15 @@ class MainActivity : FlutterActivity() {
tmpDir,
Aapt.binary(applicationContext).absolutePath,
tmpDir.path,
true // TODO: Add option to disable this
)
)

if (cancel(patcher::close)) return@Thread
updateProgress(0.02, "Loading patches...", "Loading patches")

val patches = patches.filter { patch ->
val isCompatible = patch.compatiblePackages?.any {
it.name == patcher.context.packageMetadata.packageName
val isCompatible = patch.compatiblePackages?.any { (name, _) ->
name == patcher.context.packageMetadata.packageName
} ?: false

val compatibleOrUniversal =
Expand All @@ -307,18 +308,15 @@ class MainActivity : FlutterActivity() {
updateProgress(0.05, "Executing...", "")

val patcherResult = patcher.use {
patcher.apply {
acceptIntegrations(setOf(integrations))
acceptPatches(patches)
}
it += patches

runBlocking {
// Update the progress bar every time a patch is executed from 0.15 to 0.7
val totalPatchesCount = patches.size
val progressStep = 0.55 / totalPatchesCount
var progress = 0.05

patcher.apply(false).collect(FlowCollector { patchResult: PatchResult ->
patcher().collect(FlowCollector { patchResult: PatchResult ->
if (cancel(patcher::close)) return@FlowCollector

val msg = patchResult.exception?.let {
Expand Down Expand Up @@ -346,10 +344,11 @@ class MainActivity : FlutterActivity() {

if (cancel(patcher::close)) return@Thread

ApkUtils.sign(
ApkUtils.signApk(
inFile,
outFile,
ApkUtils.SigningOptions(
"ReVanced",
ApkUtils.KeyStoreDetails(
keyStoreFile,
keystorePassword,
"alias",
Expand Down
12 changes: 11 additions & 1 deletion android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import com.android.build.api.dsl.CommonExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

allprojects {
repositories {
Expand All @@ -17,11 +18,20 @@ allprojects {

layout.buildDirectory = File("../build")

project(":screenshot_callback") {
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "17"
}
}
}

subprojects {
afterEvaluate {
extensions.findByName("android")?.let {
it as CommonExtension<*, *, *, *, *, *>
it.compileSdk = 34
if (it.compileSdk != null && it.compileSdk!! < 31)
it.compileSdk = 34
}
}

Expand Down
1 change: 0 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@ android.useAndroidX=true
org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.caching=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
6 changes: 3 additions & 3 deletions android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[versions]
revanced-patcher = "19.3.1" # TODO: Update to non-dev
revanced-library = "2.2.1"
desugar_jdk_libs = "2.1.2"
revanced-patcher = "21.0.0"
revanced-library = "3.0.2"
desugar_jdk_libs = "2.1.3"

[libraries]
revanced-patcher = { module = "app.revanced:revanced-patcher", version.ref = "revanced-patcher" }
Expand Down
2 changes: 1 addition & 1 deletion android/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pluginManagement {

plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "8.7.0" apply false
id("com.android.application") version "8.7.2" apply false
id("org.jetbrains.kotlin.android") version "2.0.20" apply false
}

Expand Down
14 changes: 9 additions & 5 deletions assets/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,20 +158,18 @@
"languageLabel": "Language",
"languageUpdated": "Language updated",
"sourcesLabel": "Alternative sources",
"sourcesLabelHint": "Configure the alternative sources for ReVanced Patches and ReVanced Integrations",
"sourcesIntegrationsLabel": "Integrations source",
"sourcesLabelHint": "Configure the alternative sources for ReVanced Patches",
"useAlternativeSources": "Use alternative sources",
"useAlternativeSourcesHint": "Use alternative sources for ReVanced Patches and ReVanced Integrations instead of the API",
"useAlternativeSourcesHint": "Use alternative sources for ReVanced Patches instead of the API",
"sourcesResetDialogTitle": "Reset",
"sourcesResetDialogText": "Are you sure you want to reset your sources to their default values?",
"apiURLResetDialogText": "Are you sure you want to reset your API URL to its default value?",
"sourcesUpdateNote": "Note: This will automatically download ReVanced Patches and ReVanced Integrations from the alternative sources.\n\nThis will connect you to the alternative source.",
"sourcesUpdateNote": "Note: This will automatically download ReVanced Patches from the alternative sources.\n\nThis will connect you to the alternative source.",
"apiURLLabel": "API URL",
"apiURLHint": "Configure the API URL of ReVanced Manager",
"selectApiURL": "API URL",
"orgPatchesLabel": "Patches organization",
"sourcesPatchesLabel": "Patches source",
"orgIntegrationsLabel": "Integrations organization",
"contributorsLabel": "Contributors",
"contributorsHint": "A list of contributors of ReVanced",
"logsLabel": "Share logs",
Expand Down Expand Up @@ -199,6 +197,12 @@
"deleteTempDirLabel": "Delete temporary files",
"deleteTempDirHint": "Delete unused temporary files",
"deletedTempDir": "Temporary files deleted",
"exportSettingsLabel": "Export settings",
"exportSettingsHint": "Export settings to a JSON file",
"exportedSettings": "Settings exported",
"importSettingsLabel": "Import settings",
"importSettingsHint": "Import settings from a JSON file",
"importedSettings": "Settings imported",
"exportPatchesLabel": "Export patch selection",
"exportPatchesHint": "Export patch selection to a JSON file",
"exportedPatches": "Patch selection exported",
Expand Down
Loading

0 comments on commit d9f0da4

Please sign in to comment.