soul-browser/sources/java/com/caverock/androidsvg/SVGImageView.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

193 lines
6.5 KiB
Java

package com.caverock.androidsvg;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Picture;
import android.graphics.drawable.PictureDrawable;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Method;
/* loaded from: classes.dex */
public class SVGImageView extends ImageView {
public static final Method f;
/* renamed from: c, reason: collision with root package name */
public SVG f2581c;
/* loaded from: classes.dex */
public class LoadResourceTask extends AsyncTask<Integer, Integer, SVG> {
/* renamed from: a, reason: collision with root package name */
public final Context f2582a;
public final int b;
public LoadResourceTask(Context context, int i) {
this.f2582a = context;
this.b = i;
}
@Override // android.os.AsyncTask
public final SVG doInBackground(Integer[] numArr) {
int i = this.b;
try {
Resources resources = this.f2582a.getResources();
SVGParser sVGParser = new SVGParser();
InputStream openRawResource = resources.openRawResource(i);
try {
SVG f = sVGParser.f(openRawResource);
try {
return f;
} catch (IOException unused) {
return f;
}
} finally {
try {
openRawResource.close();
} catch (IOException unused2) {
}
}
} catch (SVGParseException e) {
Log.e("SVGImageView", String.format("Error loading resource 0x%x: %s", Integer.valueOf(i), e.getMessage()));
return null;
}
}
@Override // android.os.AsyncTask
public final void onPostExecute(SVG svg) {
SVGImageView sVGImageView = SVGImageView.this;
sVGImageView.f2581c = svg;
sVGImageView.a();
}
}
/* loaded from: classes.dex */
public class LoadURITask extends AsyncTask<InputStream, Integer, SVG> {
public LoadURITask() {
}
/* JADX WARN: Multi-variable type inference failed */
/* JADX WARN: Type inference failed for: r2v1, types: [java.io.InputStream] */
/* JADX WARN: Type inference failed for: r6v1, types: [java.io.InputStream[]] */
/* JADX WARN: Type inference failed for: r6v2 */
/* JADX WARN: Type inference failed for: r6v3 */
/* JADX WARN: Type inference failed for: r6v4, types: [java.io.InputStream] */
/* JADX WARN: Type inference failed for: r6v5 */
/* JADX WARN: Type inference failed for: r6v6, types: [java.io.InputStream] */
/* JADX WARN: Type inference failed for: r6v7, types: [java.io.InputStream] */
@Override // android.os.AsyncTask
public final SVG doInBackground(InputStream[] inputStreamArr) {
SVG svg;
InputStream[] inputStreamArr2 = inputStreamArr;
try {
try {
svg = SVG.b(inputStreamArr2[0]);
try {
inputStreamArr2[0].close();
return svg;
} catch (IOException unused) {
return svg;
}
} catch (Throwable th) {
try {
inputStreamArr2[0].close();
} catch (IOException unused2) {
}
throw th;
}
} catch (SVGParseException e) {
Log.e("SVGImageView", "Parse error loading URI: " + e.getMessage());
try {
inputStreamArr2 = inputStreamArr2[0];
inputStreamArr2.close();
} catch (IOException unused3) {
}
svg = null;
return svg;
}
}
@Override // android.os.AsyncTask
public final void onPostExecute(SVG svg) {
SVGImageView sVGImageView = SVGImageView.this;
sVGImageView.f2581c = svg;
sVGImageView.a();
}
}
static {
try {
f = View.class.getMethod("setLayerType", Integer.TYPE, Paint.class);
} catch (NoSuchMethodException unused) {
}
}
private void setFromString(String str) {
try {
this.f2581c = new SVGParser().f(new ByteArrayInputStream(str.getBytes()));
a();
} catch (SVGParseException unused) {
Log.e("SVGImageView", "Could not find SVG at: " + str);
}
}
public final void a() {
SVG svg = this.f2581c;
if (svg == null) {
return;
}
Picture d = svg.d();
Method method = f;
if (method != null) {
try {
method.invoke(this, Integer.valueOf(View.class.getField("LAYER_TYPE_SOFTWARE").getInt(new View(getContext()))), null);
} catch (Exception e) {
Log.w("SVGImageView", "Unexpected failure calling setLayerType", e);
}
}
setImageDrawable(new PictureDrawable(d));
}
public void setCSS(String str) {
throw null;
}
public void setImageAsset(String str) {
try {
new LoadURITask().execute(getContext().getAssets().open(str));
} catch (IOException unused) {
Log.e("SVGImageView", "File not found: " + str);
}
}
@Override // android.widget.ImageView
public void setImageResource(int i) {
new LoadResourceTask(getContext(), i).execute(new Integer[0]);
}
@Override // android.widget.ImageView
public void setImageURI(Uri uri) {
try {
new LoadURITask().execute(getContext().getContentResolver().openInputStream(uri));
} catch (FileNotFoundException unused) {
Log.e("SVGImageView", "File not found: " + uri);
}
}
public void setSVG(SVG svg) {
if (svg != null) {
this.f2581c = svg;
a();
return;
}
throw new IllegalArgumentException("Null value passed to setSVG()");
}
}