soul-browser/app/smali/androidx/profileinstaller/Encoding.smali
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

631 lines
11 KiB
Smali

.class Landroidx/profileinstaller/Encoding;
.super Ljava/lang/Object;
.source "SourceFile"
# annotations
.annotation build Landroidx/annotation/RequiresApi;
.end annotation
# direct methods
.method public static a([B)[B
.locals 3
.line 1
new-instance v0, Ljava/util/zip/Deflater;
.line 2
.line 3
const/4 v1, 0x1
.line 4
invoke-direct {v0, v1}, Ljava/util/zip/Deflater;-><init>(I)V
.line 5
.line 6
.line 7
new-instance v1, Ljava/io/ByteArrayOutputStream;
.line 8
.line 9
invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V
.line 10
.line 11
.line 12
:try_start_0
new-instance v2, Ljava/util/zip/DeflaterOutputStream;
.line 13
.line 14
invoke-direct {v2, v1, v0}, Ljava/util/zip/DeflaterOutputStream;-><init>(Ljava/io/OutputStream;Ljava/util/zip/Deflater;)V
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 15
.line 16
.line 17
:try_start_1
invoke-virtual {v2, p0}, Ljava/io/OutputStream;->write([B)V
:try_end_1
.catchall {:try_start_1 .. :try_end_1} :catchall_1
.line 18
.line 19
.line 20
:try_start_2
invoke-virtual {v2}, Ljava/util/zip/DeflaterOutputStream;->close()V
:try_end_2
.catchall {:try_start_2 .. :try_end_2} :catchall_0
.line 21
.line 22
.line 23
invoke-virtual {v0}, Ljava/util/zip/Deflater;->end()V
.line 24
.line 25
.line 26
invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
.line 27
.line 28
.line 29
move-result-object p0
.line 30
return-object p0
.line 31
:catchall_0
move-exception p0
.line 32
goto :goto_1
.line 33
:catchall_1
move-exception p0
.line 34
:try_start_3
invoke-virtual {v2}, Ljava/util/zip/DeflaterOutputStream;->close()V
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_2
.line 35
.line 36
.line 37
goto :goto_0
.line 38
:catchall_2
move-exception v1
.line 39
:try_start_4
invoke-virtual {p0, v1}, Ljava/lang/Throwable;->addSuppressed(Ljava/lang/Throwable;)V
.line 40
.line 41
.line 42
:goto_0
throw p0
:try_end_4
.catchall {:try_start_4 .. :try_end_4} :catchall_0
.line 43
:goto_1
invoke-virtual {v0}, Ljava/util/zip/Deflater;->end()V
.line 44
.line 45
.line 46
throw p0
.end method
.method public static b(Ljava/io/InputStream;I)[B
.locals 3
.line 1
new-array v0, p1, [B
.line 2
.line 3
const/4 v1, 0x0
.line 4
:goto_0
if-ge v1, p1, :cond_1
.line 5
.line 6
sub-int v2, p1, v1
.line 7
.line 8
invoke-virtual {p0, v0, v1, v2}, Ljava/io/InputStream;->read([BII)I
.line 9
.line 10
.line 11
move-result v2
.line 12
if-ltz v2, :cond_0
.line 13
.line 14
add-int/2addr v1, v2
.line 15
goto :goto_0
.line 16
:cond_0
const-string p0, "Not enough bytes to read: "
.line 17
.line 18
invoke-static {p1, p0}, Landroid/support/v4/media/a;->e(ILjava/lang/String;)Ljava/lang/String;
.line 19
.line 20
.line 21
move-result-object p0
.line 22
new-instance p1, Ljava/lang/IllegalStateException;
.line 23
.line 24
invoke-direct {p1, p0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
.line 25
.line 26
.line 27
throw p1
.line 28
:cond_1
return-object v0
.end method
.method public static c(Ljava/io/FileInputStream;II)[B
.locals 8
.line 1
new-instance v0, Ljava/util/zip/Inflater;
.line 2
.line 3
invoke-direct {v0}, Ljava/util/zip/Inflater;-><init>()V
.line 4
.line 5
.line 6
:try_start_0
new-array v1, p2, [B
.line 7
.line 8
const/16 v2, 0x800
.line 9
.line 10
new-array v2, v2, [B
.line 11
.line 12
const/4 v3, 0x0
.line 13
move v4, v3
.line 14
move v5, v4
.line 15
:goto_0
invoke-virtual {v0}, Ljava/util/zip/Inflater;->finished()Z
.line 16
.line 17
.line 18
move-result v6
.line 19
if-nez v6, :cond_1
.line 20
.line 21
invoke-virtual {v0}, Ljava/util/zip/Inflater;->needsDictionary()Z
.line 22
.line 23
.line 24
move-result v6
.line 25
if-nez v6, :cond_1
.line 26
.line 27
if-ge v4, p1, :cond_1
.line 28
.line 29
invoke-virtual {p0, v2}, Ljava/io/InputStream;->read([B)I
.line 30
.line 31
.line 32
move-result v6
.line 33
if-ltz v6, :cond_0
.line 34
.line 35
invoke-virtual {v0, v2, v3, v6}, Ljava/util/zip/Inflater;->setInput([BII)V
:try_end_0
.catchall {:try_start_0 .. :try_end_0} :catchall_0
.line 36
.line 37
.line 38
sub-int v7, p2, v5
.line 39
.line 40
:try_start_1
invoke-virtual {v0, v1, v5, v7}, Ljava/util/zip/Inflater;->inflate([BII)I
.line 41
.line 42
.line 43
move-result v7
:try_end_1
.catch Ljava/util/zip/DataFormatException; {:try_start_1 .. :try_end_1} :catch_0
.catchall {:try_start_1 .. :try_end_1} :catchall_0
.line 44
add-int/2addr v5, v7
.line 45
add-int/2addr v4, v6
.line 46
goto :goto_0
.line 47
:catchall_0
move-exception p0
.line 48
goto :goto_1
.line 49
:catch_0
move-exception p0
.line 50
:try_start_2
invoke-virtual {p0}, Ljava/lang/Throwable;->getMessage()Ljava/lang/String;
.line 51
.line 52
.line 53
move-result-object p0
.line 54
new-instance p1, Ljava/lang/IllegalStateException;
.line 55
.line 56
invoke-direct {p1, p0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
.line 57
.line 58
.line 59
throw p1
.line 60
:cond_0
new-instance p0, Ljava/lang/StringBuilder;
.line 61
.line 62
invoke-direct {p0}, Ljava/lang/StringBuilder;-><init>()V
.line 63
.line 64
.line 65
const-string p2, "Invalid zip data. Stream ended after $totalBytesRead bytes. Expected "
.line 66
.line 67
invoke-virtual {p0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 68
.line 69
.line 70
invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
.line 71
.line 72
.line 73
const-string p1, " bytes"
.line 74
.line 75
invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 76
.line 77
.line 78
invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
.line 79
.line 80
.line 81
move-result-object p0
.line 82
new-instance p1, Ljava/lang/IllegalStateException;
.line 83
.line 84
invoke-direct {p1, p0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
.line 85
.line 86
.line 87
throw p1
.line 88
:cond_1
if-ne v4, p1, :cond_3
.line 89
.line 90
invoke-virtual {v0}, Ljava/util/zip/Inflater;->finished()Z
.line 91
.line 92
.line 93
move-result p0
:try_end_2
.catchall {:try_start_2 .. :try_end_2} :catchall_0
.line 94
if-eqz p0, :cond_2
.line 95
.line 96
invoke-virtual {v0}, Ljava/util/zip/Inflater;->end()V
.line 97
.line 98
.line 99
return-object v1
.line 100
:cond_2
:try_start_3
const-string p0, "Inflater did not finish"
.line 101
.line 102
new-instance p1, Ljava/lang/IllegalStateException;
.line 103
.line 104
invoke-direct {p1, p0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
.line 105
.line 106
.line 107
throw p1
.line 108
:cond_3
new-instance p0, Ljava/lang/StringBuilder;
.line 109
.line 110
invoke-direct {p0}, Ljava/lang/StringBuilder;-><init>()V
.line 111
.line 112
.line 113
const-string p2, "Didn\'t read enough bytes during decompression. expected="
.line 114
.line 115
invoke-virtual {p0, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 116
.line 117
.line 118
invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
.line 119
.line 120
.line 121
const-string p1, " actual="
.line 122
.line 123
invoke-virtual {p0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 124
.line 125
.line 126
invoke-virtual {p0, v4}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
.line 127
.line 128
.line 129
invoke-virtual {p0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
.line 130
.line 131
.line 132
move-result-object p0
.line 133
new-instance p1, Ljava/lang/IllegalStateException;
.line 134
.line 135
invoke-direct {p1, p0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
.line 136
.line 137
.line 138
throw p1
:try_end_3
.catchall {:try_start_3 .. :try_end_3} :catchall_0
.line 139
:goto_1
invoke-virtual {v0}, Ljava/util/zip/Inflater;->end()V
.line 140
.line 141
.line 142
throw p0
.end method
.method public static d(Ljava/io/InputStream;I)J
.locals 6
.line 1
invoke-static {p0, p1}, Landroidx/profileinstaller/Encoding;->b(Ljava/io/InputStream;I)[B
.line 2
.line 3
.line 4
move-result-object p0
.line 5
const-wide/16 v0, 0x0
.line 6
.line 7
const/4 v2, 0x0
.line 8
:goto_0
if-ge v2, p1, :cond_0
.line 9
.line 10
aget-byte v3, p0, v2
.line 11
.line 12
and-int/lit16 v3, v3, 0xff
.line 13
.line 14
int-to-long v3, v3
.line 15
mul-int/lit8 v5, v2, 0x8
.line 16
.line 17
shl-long/2addr v3, v5
.line 18
add-long/2addr v0, v3
.line 19
add-int/lit8 v2, v2, 0x1
.line 20
.line 21
goto :goto_0
.line 22
:cond_0
return-wide v0
.end method
.method public static e(Ljava/io/ByteArrayOutputStream;JI)V
.locals 6
.line 1
new-array v0, p3, [B
.line 2
.line 3
const/4 v1, 0x0
.line 4
:goto_0
if-ge v1, p3, :cond_0
.line 5
.line 6
mul-int/lit8 v2, v1, 0x8
.line 7
.line 8
shr-long v2, p1, v2
.line 9
.line 10
const-wide/16 v4, 0xff
.line 11
.line 12
and-long/2addr v2, v4
.line 13
long-to-int v2, v2
.line 14
int-to-byte v2, v2
.line 15
aput-byte v2, v0, v1
.line 16
.line 17
add-int/lit8 v1, v1, 0x1
.line 18
.line 19
goto :goto_0
.line 20
:cond_0
invoke-virtual {p0, v0}, Ljava/io/OutputStream;->write([B)V
.line 21
.line 22
.line 23
return-void
.end method
.method public static f(Ljava/io/ByteArrayOutputStream;I)V
.locals 2
.line 1
int-to-long v0, p1
.line 2
const/4 p1, 0x2
.line 3
invoke-static {p0, v0, v1, p1}, Landroidx/profileinstaller/Encoding;->e(Ljava/io/ByteArrayOutputStream;JI)V
.line 4
.line 5
.line 6
return-void
.end method