@@ -21,6 +21,7 @@ class AlignmentStep : Step(), KoinComponent {
21
21
override val localizedName = R .string.patch_step_alignment
22
22
23
23
override suspend fun execute (container : StepRunner ) {
24
+ val currentDeviceArch = Build .SUPPORTED_ABIS .first()
24
25
val apk = container.getStep<CopyDependenciesStep >().patchedApk
25
26
26
27
var resourcesArscBytes: ByteArray? = null
@@ -52,12 +53,19 @@ class AlignmentStep : Step(), KoinComponent {
52
53
// Align native libs due to using extractNativeLibs
53
54
nativeLibPaths = ZipReader (apk).use { zip ->
54
55
val libPaths = zip.entryNames.filter { it.endsWith(" .so" ) }
56
+
57
+ // Extract to disk temporarily
55
58
for ((idx, path) in libPaths.withIndex()) {
59
+ // Ignore lib architectures that don't match this device
60
+ if (! path.startsWith(" lib/$currentDeviceArch " ))
61
+ continue
62
+
56
63
// Index is just used as a placeholder id to cache on disk
57
64
val bytes = zip.openEntry(path)!! .read()
58
65
val file = paths.patchingWorkingDir().resolve(" $idx .so" )
59
66
file.writeBytes(bytes)
60
67
}
68
+
61
69
libPaths
62
70
}
63
71
@@ -84,6 +92,10 @@ class AlignmentStep : Step(), KoinComponent {
84
92
85
93
// Write back native libraries aligned to 16KiB page boundary
86
94
for ((idx, path) in nativeLibPaths.withIndex()) {
95
+ // Ignore lib architectures that don't match this device
96
+ if (! path.startsWith(" lib/$currentDeviceArch " ))
97
+ continue
98
+
87
99
val file = paths.patchingWorkingDir().resolve(" $idx .so" )
88
100
val bytes = file.readBytes()
89
101
zip.writeEntry(path, bytes, ZipCompression .NONE , 16384 )
0 commit comments