Skip to content

Commit fe5fb73

Browse files
committed
build: Bump dependencies
1 parent fc505a8 commit fe5fb73

File tree

5 files changed

+79
-61
lines changed

5 files changed

+79
-61
lines changed

api/revanced-patcher.api

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public final class app/revanced/patcher/Patcher : java/io/Closeable {
7373
}
7474

7575
public final class app/revanced/patcher/PatcherConfig {
76+
public fun <init> (Ljava/io/File;Ljava/io/File;Ljava/io/File;Ljava/lang/String;)V
77+
public synthetic fun <init> (Ljava/io/File;Ljava/io/File;Ljava/io/File;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
7678
public fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;)V
7779
public synthetic fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
7880
}

gradle.properties

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
org.gradle.parallel = true
2-
org.gradle.caching = true
3-
version = 21.1.0-dev.1
1+
org.gradle.parallel=true
2+
org.gradle.caching=true
3+
version=21.1.0-dev.1

gradle/libs.versions.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
[versions]
22
android = "4.1.1.4"
3-
apktool-lib = "2.9.3"
3+
apktool-lib = "2.10.1.1"
44
binary-compatibility-validator = "0.15.1"
5-
kotlin = "2.0.0"
5+
kotlin = "2.0.20"
66
kotlinx-coroutines-core = "1.8.1"
77
mockk = "1.13.10"
88
multidexlib2 = "3.0.3.r3"
99
# Tracking https://github.com/google/smali/issues/64.
1010
#noinspection GradleDependency
11-
smali = "3.0.5"
11+
smali = "3.0.8"
1212
xpp3 = "1.1.4c"
1313

1414
[libraries]

src/main/kotlin/app/revanced/patcher/PatcherConfig.kt

+21-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,28 @@ import java.util.logging.Logger
1616
class PatcherConfig(
1717
internal val apkFile: File,
1818
private val temporaryFilesPath: File = File("revanced-temporary-files"),
19-
aaptBinaryPath: String? = null,
19+
aaptBinaryPath: File? = null,
2020
frameworkFileDirectory: String? = null,
2121
) {
22+
/**
23+
* The configuration for the patcher.
24+
*
25+
* @param apkFile The apk file to patch.
26+
* @param temporaryFilesPath A path to a folder to store temporary files in.
27+
* @param aaptBinaryPath A path to a custom aapt binary.
28+
* @param frameworkFileDirectory A path to the directory to cache the framework file in.
29+
*/
30+
@Deprecated(
31+
"Use the constructor with a File for aaptBinaryPath instead.",
32+
ReplaceWith("PatcherConfig(apkFile, temporaryFilesPath, aaptBinaryPath?.let { File(it) }, frameworkFileDirectory)"),
33+
)
34+
constructor(
35+
apkFile: File,
36+
temporaryFilesPath: File = File("revanced-temporary-files"),
37+
aaptBinaryPath: String? = null,
38+
frameworkFileDirectory: String? = null,
39+
) : this(apkFile, temporaryFilesPath, aaptBinaryPath?.let { File(it) }, frameworkFileDirectory)
40+
2241
private val logger = Logger.getLogger(PatcherConfig::class.java.name)
2342

2443
/**
@@ -33,8 +52,7 @@ class PatcherConfig(
3352
*/
3453
internal val resourceConfig =
3554
Config.getDefaultConfig().apply {
36-
useAapt2 = true
37-
aaptPath = aaptBinaryPath ?: ""
55+
aaptBinary = aaptBinaryPath
3856
frameworkDirectory = frameworkFileDirectory
3957
}
4058

src/main/kotlin/app/revanced/patcher/patch/ResourcePatchContext.kt

+50-52
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import brut.androlib.ApkDecoder
1010
import brut.androlib.apk.UsesFramework
1111
import brut.androlib.res.Framework
1212
import brut.androlib.res.ResourcesDecoder
13+
import brut.androlib.res.decoder.AndroidManifestPullStreamDecoder
1314
import brut.androlib.res.decoder.AndroidManifestResourceParser
14-
import brut.androlib.res.decoder.XmlPullStreamDecoder
15-
import brut.androlib.res.xml.ResXmlPatcher
15+
import brut.androlib.res.xml.ResXmlUtils
1616
import brut.directory.ExtFile
1717
import java.io.InputStream
1818
import java.io.OutputStream
@@ -51,64 +51,62 @@ class ResourcePatchContext internal constructor(
5151
*
5252
* @param mode The [ResourceMode] to use.
5353
*/
54-
internal fun decodeResources(mode: ResourceMode) =
55-
with(packageMetadata.apkInfo) {
56-
config.initializeTemporaryFilesDirectories()
54+
internal fun decodeResources(mode: ResourceMode) = with(packageMetadata.apkInfo) {
55+
config.initializeTemporaryFilesDirectories()
5756

58-
// Needed to decode resources.
59-
val resourcesDecoder = ResourcesDecoder(config.resourceConfig, this)
57+
// Needed to decode resources.
58+
val resourcesDecoder = ResourcesDecoder(config.resourceConfig, this)
6059

61-
if (mode == ResourceMode.FULL) {
62-
logger.info("Decoding resources")
60+
if (mode == ResourceMode.FULL) {
61+
logger.info("Decoding resources")
6362

64-
resourcesDecoder.decodeResources(config.apkFiles)
65-
resourcesDecoder.decodeManifest(config.apkFiles)
63+
resourcesDecoder.decodeResources(config.apkFiles)
64+
resourcesDecoder.decodeManifest(config.apkFiles)
6665

67-
// Needed to record uncompressed files.
68-
val apkDecoder = ApkDecoder(config.resourceConfig, this)
69-
apkDecoder.recordUncompressedFiles(resourcesDecoder.resFileMapping)
66+
// Needed to record uncompressed files.
67+
ApkDecoder(this, config.resourceConfig).recordUncompressedFiles(resourcesDecoder.resFileMapping)
7068

71-
usesFramework =
72-
UsesFramework().apply {
73-
ids = resourcesDecoder.resTable.listFramePackages().map { it.id }
74-
}
75-
} else {
76-
logger.info("Decoding app manifest")
77-
78-
// Decode manually instead of using resourceDecoder.decodeManifest
79-
// because it does not support decoding to an OutputStream.
80-
XmlPullStreamDecoder(
81-
AndroidManifestResourceParser(resourcesDecoder.resTable),
82-
resourcesDecoder.resXmlSerializer,
83-
).decodeManifest(
84-
apkFile.directory.getFileInput("AndroidManifest.xml"),
85-
// Older Android versions do not support OutputStream.nullOutputStream()
86-
object : OutputStream() {
87-
override fun write(b: Int) { // Do nothing.
88-
}
89-
},
90-
)
91-
92-
// Get the package name and version from the manifest using the XmlPullStreamDecoder.
93-
// XmlPullStreamDecoder.decodeManifest() sets metadata.apkInfo.
94-
packageMetadata.let { metadata ->
95-
metadata.packageName = resourcesDecoder.resTable.packageRenamed
96-
versionInfo.let {
97-
metadata.packageVersion = it.versionName ?: it.versionCode
69+
usesFramework =
70+
UsesFramework().apply {
71+
ids = resourcesDecoder.resTable.listFramePackages().map { it.id }
72+
}
73+
} else {
74+
logger.info("Decoding app manifest")
75+
76+
// Decode manually instead of using resourceDecoder.decodeManifest
77+
// because it does not support decoding to an OutputStream.
78+
AndroidManifestPullStreamDecoder(
79+
AndroidManifestResourceParser(resourcesDecoder.resTable),
80+
resourcesDecoder.newXmlSerializer(),
81+
).decode(
82+
apkFile.directory.getFileInput("AndroidManifest.xml"),
83+
// Older Android versions do not support OutputStream.nullOutputStream()
84+
object : OutputStream() {
85+
override fun write(b: Int) { // Do nothing.
9886
}
87+
},
88+
)
89+
90+
// Get the package name and version from the manifest using the XmlPullStreamDecoder.
91+
// AndroidManifestPullStreamDecoder.decode() sets metadata.apkInfo.
92+
packageMetadata.let { metadata ->
93+
metadata.packageName = resourcesDecoder.resTable.packageRenamed
94+
versionInfo.let {
95+
metadata.packageVersion = it.versionName ?: it.versionCode
96+
}
9997

100-
/*
101-
The ResTable if flagged as sparse if the main package is not loaded, which is the case here,
102-
because ResourcesDecoder.decodeResources loads the main package
103-
and not XmlPullStreamDecoder.decodeManifest.
104-
See ARSCDecoder.readTableType for more info.
98+
/*
99+
The ResTable if flagged as sparse if the main package is not loaded, which is the case here,
100+
because ResourcesDecoder.decodeResources loads the main package
101+
and not AndroidManifestPullStreamDecoder.decode.
102+
See ARSCDecoder.readTableType for more info.
105103
106-
Set this to false again to prevent the ResTable from being flagged as sparse falsely.
107-
*/
108-
metadata.apkInfo.sparseResources = false
109-
}
104+
Set this to false again to prevent the ResTable from being flagged as sparse falsely.
105+
*/
106+
metadata.apkInfo.sparseResources = false
110107
}
111108
}
109+
}
112110

113111
/**
114112
* Compile resources in [PatcherConfig.apkFiles].
@@ -130,10 +128,10 @@ class ResourcePatchContext internal constructor(
130128
AaptInvoker(
131129
config.resourceConfig,
132130
packageMetadata.apkInfo,
133-
).invokeAapt(
131+
).invoke(
134132
resources.resolve("resources.apk"),
135133
config.apkFiles.resolve("AndroidManifest.xml").also {
136-
ResXmlPatcher.fixingPublicAttrsInProviderAttributes(it)
134+
ResXmlUtils.fixingPublicAttrsInProviderAttributes(it)
137135
},
138136
config.apkFiles.resolve("res"),
139137
null,

0 commit comments

Comments
 (0)