soul-browser/sources/java/androidx/profileinstaller/Encoding.java
KaKi87 550ddb0413
Decompile and recreate Soul Browser v1.4.85 with APK CI builds (#1)
* Decompile and recreate Soul Browser v1.4.85 with APK CI builds

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix CI build: include bundled google.jks and remove PR trigger

The apktool build failed in CI because app/unknown/.../google.jks was
excluded by the *.jks gitignore rule. Whitelist app-bundled JKS files
and commit the missing resource.

Also remove the redundant pull_request workflow trigger.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Change package ID to com.github.kaki87.soulbrowser

Rename the application ID so the rebuilt APK can be installed
alongside the original Soul Browser from Google Play.

- Update AndroidManifest package, permissions, providers, and actions
- Update R class references in smali (com/github/kaki87/soulbrowser/R)
- Update shortcuts.xml targetPackage
- Rename app label to "Soul Rebuild" for easy identification

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix install compatibility: remove split APK metadata and bundle native libs

The rebuilt APK still declared requiredSplitTypes and Play Store split
metadata, causing Android to reject standalone installs as incompatible.

- Remove requiredSplitTypes and split-related manifest meta-data
- Merge native libs from all ABI splits with uncompressed storage
- Page-align before signing for extractNativeLibs=false
- Add .so to apktool doNotCompress list

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix install failure: use apksigner v2/v3 and bundle arm64 native libs

Target SDK 36 requires APK Signature Scheme v2+, but jarsigner only
produces v1 signatures, causing Android to reject the install.

- Sign with apksigner (v1+v2+v3) instead of jarsigner
- Add arm64-v8a native libraries from universal Soul Browser 1.4.79
- Set extractNativeLibs=true for reliable sideload installs
- Commit stable debug keystore for consistent signatures across builds

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Add committed debug keystore for consistent APK signatures

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix startup crash: use original classes2.dex desugar libraries

Apktool recompiles smali_classes2 into a broken classes2.dex, causing
ClassNotFoundException for j$.com.android.tools.r8.a at ML Kit init.

Inject the original classes2.dex (Java 8+ desugar libs) after apktool
build instead of using the recompiled version.

Co-authored-by: KaKi87 <KaKi87@pm.me>

* Fix missing drawable resources from density split APKs

The base APK is an app bundle module; density-specific drawables like
seek_thumb_nor_b live in config.xhdpi.apk and were missing after rebuild,
causing Resources$NotFoundException at runtime.

- Merge non-9-patch resources from split APKs before apktool build
- Sync public.xml IDs from R smali only when backing files exist
- Add 713 density-specific resource IDs to public.xml

Co-authored-by: KaKi87 <KaKi87@pm.me>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-08-10 16:07:14 +02:00

157 lines
6.6 KiB
Java

package androidx.profileinstaller;
import androidx.annotation.RequiresApi;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.util.zip.Deflater;
import java.util.zip.DeflaterOutputStream;
import kotlin.UByte;
@RequiresApi
/* loaded from: classes.dex */
class Encoding {
public static byte[] a(byte[] bArr) {
Deflater deflater = new Deflater(1);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
DeflaterOutputStream deflaterOutputStream = new DeflaterOutputStream(byteArrayOutputStream, deflater);
try {
deflaterOutputStream.write(bArr);
deflaterOutputStream.close();
deflater.end();
return byteArrayOutputStream.toByteArray();
} finally {
}
} catch (Throwable th) {
deflater.end();
throw th;
}
}
public static byte[] b(InputStream inputStream, int i) {
byte[] bArr = new byte[i];
int i2 = 0;
while (i2 < i) {
int read = inputStream.read(bArr, i2, i - i2);
if (read >= 0) {
i2 += read;
} else {
throw new IllegalStateException(android.support.v4.media.a.e(i, "Not enough bytes to read: "));
}
}
return bArr;
}
/* JADX WARN: Code restructure failed: missing block: B:27:0x005d, code lost:
if (r0.finished() == false) goto L27;
*/
/* JADX WARN: Code restructure failed: missing block: B:29:0x0062, code lost:
return r1;
*/
/* JADX WARN: Code restructure failed: missing block: B:31:0x006a, code lost:
throw new java.lang.IllegalStateException("Inflater did not finish");
*/
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public static byte[] c(java.io.FileInputStream r8, int r9, int r10) {
/*
java.util.zip.Inflater r0 = new java.util.zip.Inflater
r0.<init>()
byte[] r1 = new byte[r10] // Catch: java.lang.Throwable -> L2e
r2 = 2048(0x800, float:2.87E-42)
byte[] r2 = new byte[r2] // Catch: java.lang.Throwable -> L2e
r3 = 0
r4 = r3
r5 = r4
Le:
boolean r6 = r0.finished() // Catch: java.lang.Throwable -> L2e
if (r6 != 0) goto L57
boolean r6 = r0.needsDictionary() // Catch: java.lang.Throwable -> L2e
if (r6 != 0) goto L57
if (r4 >= r9) goto L57
int r6 = r8.read(r2) // Catch: java.lang.Throwable -> L2e
if (r6 < 0) goto L3b
r0.setInput(r2, r3, r6) // Catch: java.lang.Throwable -> L2e
int r7 = r10 - r5
int r7 = r0.inflate(r1, r5, r7) // Catch: java.lang.Throwable -> L2e java.util.zip.DataFormatException -> L30
int r5 = r5 + r7
int r4 = r4 + r6
goto Le
L2e:
r8 = move-exception
goto L8a
L30:
r8 = move-exception
java.lang.String r8 = r8.getMessage() // Catch: java.lang.Throwable -> L2e
java.lang.IllegalStateException r9 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L2e
r9.<init>(r8) // Catch: java.lang.Throwable -> L2e
throw r9 // Catch: java.lang.Throwable -> L2e
L3b:
java.lang.StringBuilder r8 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L2e
r8.<init>() // Catch: java.lang.Throwable -> L2e
java.lang.String r10 = "Invalid zip data. Stream ended after $totalBytesRead bytes. Expected "
r8.append(r10) // Catch: java.lang.Throwable -> L2e
r8.append(r9) // Catch: java.lang.Throwable -> L2e
java.lang.String r9 = " bytes"
r8.append(r9) // Catch: java.lang.Throwable -> L2e
java.lang.String r8 = r8.toString() // Catch: java.lang.Throwable -> L2e
java.lang.IllegalStateException r9 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L2e
r9.<init>(r8) // Catch: java.lang.Throwable -> L2e
throw r9 // Catch: java.lang.Throwable -> L2e
L57:
if (r4 != r9) goto L6b
boolean r8 = r0.finished() // Catch: java.lang.Throwable -> L2e
if (r8 == 0) goto L63
r0.end()
return r1
L63:
java.lang.String r8 = "Inflater did not finish"
java.lang.IllegalStateException r9 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L2e
r9.<init>(r8) // Catch: java.lang.Throwable -> L2e
throw r9 // Catch: java.lang.Throwable -> L2e
L6b:
java.lang.StringBuilder r8 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L2e
r8.<init>() // Catch: java.lang.Throwable -> L2e
java.lang.String r10 = "Didn't read enough bytes during decompression. expected="
r8.append(r10) // Catch: java.lang.Throwable -> L2e
r8.append(r9) // Catch: java.lang.Throwable -> L2e
java.lang.String r9 = " actual="
r8.append(r9) // Catch: java.lang.Throwable -> L2e
r8.append(r4) // Catch: java.lang.Throwable -> L2e
java.lang.String r8 = r8.toString() // Catch: java.lang.Throwable -> L2e
java.lang.IllegalStateException r9 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L2e
r9.<init>(r8) // Catch: java.lang.Throwable -> L2e
throw r9 // Catch: java.lang.Throwable -> L2e
L8a:
r0.end()
throw r8
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.profileinstaller.Encoding.c(java.io.FileInputStream, int, int):byte[]");
}
public static long d(InputStream inputStream, int i) {
byte[] b = b(inputStream, i);
long j = 0;
for (int i2 = 0; i2 < i; i2++) {
j += (b[i2] & UByte.MAX_VALUE) << (i2 * 8);
}
return j;
}
public static void e(ByteArrayOutputStream byteArrayOutputStream, long j, int i) {
byte[] bArr = new byte[i];
for (int i2 = 0; i2 < i; i2++) {
bArr[i2] = (byte) ((j >> (i2 * 8)) & 255);
}
byteArrayOutputStream.write(bArr);
}
public static void f(ByteArrayOutputStream byteArrayOutputStream, int i) {
e(byteArrayOutputStream, i, 2);
}
}