soul-browser/sources/java/okio/RealBufferedSink.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

200 lines
8.2 KiB
Java

package okio;
import java.nio.ByteBuffer;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.SourceDebugExtension;
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\b\u0000\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lokio/RealBufferedSink;", "Lokio/BufferedSink;", "okio"}, k = 1, mv = {2, 2, 0}, xi = 48)
@SourceDebugExtension({"SMAP\nRealBufferedSink.kt\nKotlin\n*S Kotlin\n*F\n+ 1 RealBufferedSink.kt\nokio/RealBufferedSink\n+ 2 RealBufferedSink.kt\nokio/internal/-RealBufferedSink\n+ 3 fake.kt\nkotlin/jvm/internal/FakeKt\n*L\n1#1,142:1\n51#1:146\n51#1:152\n51#1:157\n51#1:162\n51#1:167\n51#1:172\n51#1:175\n51#1:176\n51#1:180\n51#1:185\n51#1:188\n51#1:192\n51#1:201\n51#1:210\n51#1:215\n51#1:220\n51#1:225\n51#1:230\n51#1:235\n51#1:240\n51#1:245\n51#1:250\n51#1:255\n51#1:261\n51#1:267\n51#1:279\n34#2:143\n35#2:145\n36#2,2:147\n40#2:149\n41#2:151\n42#2:153\n50#2:154\n51#2:156\n52#2:158\n56#2:159\n57#2:161\n58#2:163\n66#2:164\n67#2:166\n68#2:168\n72#2:169\n73#2:171\n74#2:173\n78#2:177\n79#2:179\n80#2:181\n88#2:182\n89#2:184\n90#2:186\n94#2,3:189\n97#2,5:193\n105#2,3:198\n108#2,5:202\n116#2:207\n117#2:209\n118#2:211\n122#2:212\n123#2:214\n124#2:216\n128#2:217\n129#2:219\n130#2:221\n134#2:222\n135#2:224\n136#2:226\n140#2:227\n141#2:229\n142#2:231\n146#2:232\n147#2:234\n148#2:236\n152#2:237\n153#2:239\n154#2:241\n158#2:242\n159#2:244\n160#2:246\n164#2:247\n165#2:249\n166#2:251\n170#2:252\n171#2:254\n172#2,2:256\n177#2:258\n178#2:260\n179#2,2:262\n184#2:264\n185#2:266\n186#2,4:268\n192#2,7:272\n199#2,16:280\n216#2:296\n218#2:297\n1#3:144\n1#3:150\n1#3:155\n1#3:160\n1#3:165\n1#3:170\n1#3:174\n1#3:178\n1#3:183\n1#3:187\n1#3:208\n1#3:213\n1#3:218\n1#3:223\n1#3:228\n1#3:233\n1#3:238\n1#3:243\n1#3:248\n1#3:253\n1#3:259\n1#3:265\n*S KotlinDebug\n*F\n+ 1 RealBufferedSink.kt\nokio/RealBufferedSink\n*L\n55#1:146\n56#1:152\n58#1:157\n59#1:162\n61#1:167\n63#1:172\n67#1:175\n78#1:176\n82#1:180\n84#1:185\n88#1:188\n93#1:192\n94#1:201\n95#1:210\n96#1:215\n97#1:220\n98#1:225\n99#1:230\n100#1:235\n101#1:240\n102#1:245\n103#1:250\n104#1:255\n105#1:261\n134#1:267\n138#1:279\n55#1:143\n55#1:145\n55#1:147,2\n56#1:149\n56#1:151\n56#1:153\n58#1:154\n58#1:156\n58#1:158\n59#1:159\n59#1:161\n59#1:163\n61#1:164\n61#1:166\n61#1:168\n63#1:169\n63#1:171\n63#1:173\n82#1:177\n82#1:179\n82#1:181\n84#1:182\n84#1:184\n84#1:186\n93#1:189,3\n93#1:193,5\n94#1:198,3\n94#1:202,5\n95#1:207\n95#1:209\n95#1:211\n96#1:212\n96#1:214\n96#1:216\n97#1:217\n97#1:219\n97#1:221\n98#1:222\n98#1:224\n98#1:226\n99#1:227\n99#1:229\n99#1:231\n100#1:232\n100#1:234\n100#1:236\n101#1:237\n101#1:239\n101#1:241\n102#1:242\n102#1:244\n102#1:246\n103#1:247\n103#1:249\n103#1:251\n104#1:252\n104#1:254\n104#1:256,2\n105#1:258\n105#1:260\n105#1:262,2\n134#1:264\n134#1:266\n134#1:268,4\n138#1:272,7\n138#1:280,16\n139#1:296\n140#1:297\n55#1:144\n56#1:150\n58#1:155\n59#1:160\n61#1:165\n63#1:170\n82#1:178\n84#1:183\n95#1:208\n96#1:213\n97#1:218\n98#1:223\n99#1:228\n100#1:233\n101#1:238\n102#1:243\n103#1:248\n104#1:253\n105#1:259\n134#1:265\n*E\n"})
/* loaded from: classes4.dex */
public final class RealBufferedSink implements BufferedSink {
/* renamed from: c, reason: collision with root package name */
public final Sink f22214c;
public final Buffer f;
public boolean g;
/* JADX WARN: Type inference failed for: r2v1, types: [okio.Buffer, java.lang.Object] */
public RealBufferedSink(Sink sink) {
Intrinsics.checkNotNullParameter(sink, "sink");
this.f22214c = sink;
this.f = new Object();
}
@Override // okio.BufferedSink
public final BufferedSink M(String string) {
Intrinsics.checkNotNullParameter(string, "string");
if (!this.g) {
this.f.S(string);
a();
return this;
}
throw new IllegalStateException("closed");
}
@Override // okio.Sink
public final void U(long j, Buffer source) {
Intrinsics.checkNotNullParameter(source, "source");
if (!this.g) {
this.f.U(j, source);
a();
return;
}
throw new IllegalStateException("closed");
}
@Override // okio.BufferedSink
public final BufferedSink Y(long j) {
if (!this.g) {
this.f.A(j);
a();
return this;
}
throw new IllegalStateException("closed");
}
public final BufferedSink a() {
if (!this.g) {
Buffer buffer = this.f;
long j = buffer.f;
if (j == 0) {
j = 0;
} else {
Segment segment = buffer.f22195c;
Intrinsics.checkNotNull(segment);
Segment segment2 = segment.g;
Intrinsics.checkNotNull(segment2);
if (segment2.f22218c < 8192 && segment2.e) {
j -= r6 - segment2.b;
}
}
if (j > 0) {
this.f22214c.U(j, buffer);
}
return this;
}
throw new IllegalStateException("closed");
}
@Override // okio.Sink, java.io.Closeable, java.lang.AutoCloseable
public final void close() {
Sink sink = this.f22214c;
if (!this.g) {
try {
Buffer buffer = this.f;
long j = buffer.f;
if (j > 0) {
sink.U(j, buffer);
}
th = null;
} catch (Throwable th) {
th = th;
}
try {
sink.close();
} catch (Throwable th2) {
if (th == null) {
th = th2;
}
}
this.g = true;
if (th != null) {
throw th;
}
}
}
@Override // okio.BufferedSink, okio.Sink, java.io.Flushable
public final void flush() {
if (!this.g) {
Buffer buffer = this.f;
long j = buffer.f;
Sink sink = this.f22214c;
if (j > 0) {
sink.U(j, buffer);
}
sink.flush();
return;
}
throw new IllegalStateException("closed");
}
@Override // java.nio.channels.Channel
public final boolean isOpen() {
return !this.g;
}
@Override // okio.BufferedSink
public final BufferedSink r0(ByteString byteString) {
Intrinsics.checkNotNullParameter(byteString, "byteString");
if (!this.g) {
this.f.n(byteString);
a();
return this;
}
throw new IllegalStateException("closed");
}
@Override // okio.Sink
public final Timeout timeout() {
return this.f22214c.timeout();
}
public final String toString() {
return "buffer(" + this.f22214c + ')';
}
@Override // java.nio.channels.WritableByteChannel
public final int write(ByteBuffer source) {
Intrinsics.checkNotNullParameter(source, "source");
if (!this.g) {
int write = this.f.write(source);
a();
return write;
}
throw new IllegalStateException("closed");
}
@Override // okio.BufferedSink
public final BufferedSink writeByte(int i) {
if (!this.g) {
this.f.v(i);
a();
return this;
}
throw new IllegalStateException("closed");
}
@Override // okio.BufferedSink
public final BufferedSink writeInt(int i) {
if (!this.g) {
this.f.F(i);
a();
return this;
}
throw new IllegalStateException("closed");
}
@Override // okio.BufferedSink
public final BufferedSink writeShort(int i) {
if (!this.g) {
this.f.L(i);
a();
return this;
}
throw new IllegalStateException("closed");
}
@Override // okio.BufferedSink
public final BufferedSink write(byte[] source) {
Intrinsics.checkNotNullParameter(source, "source");
if (!this.g) {
Intrinsics.checkNotNullParameter(source, "source");
this.f.o(source, source.length);
a();
return this;
}
throw new IllegalStateException("closed");
}
}