soul-browser/sources/java/androidx/appcompat/widget/DrawableUtils.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

210 lines
7.7 KiB
Java

package androidx.appcompat.widget;
import android.R;
import android.graphics.Insets;
import android.graphics.PorterDuff;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import androidx.annotation.DoNotInline;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.graphics.drawable.WrappedDrawable;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@RestrictTo
/* loaded from: classes.dex */
public class DrawableUtils {
/* renamed from: a, reason: collision with root package name */
public static final int[] f290a = {R.attr.state_checked};
public static final int[] b = new int[0];
/* renamed from: c, reason: collision with root package name */
public static final Rect f291c = new Rect();
/* loaded from: classes.dex */
public static class Api18Impl {
/* renamed from: a, reason: collision with root package name */
public static final boolean f292a;
public static final Method b;
/* renamed from: c, reason: collision with root package name */
public static final Field f293c;
public static final Field d;
public static final Field e;
public static final Field f;
/* JADX WARN: Removed duplicated region for block: B:15:0x004a */
/* JADX WARN: Removed duplicated region for block: B:18:0x0057 */
static {
/*
r0 = 1
r1 = 0
r2 = 0
java.lang.String r3 = "android.graphics.Insets"
java.lang.Class r3 = java.lang.Class.forName(r3) // Catch: java.lang.NoSuchFieldException -> L3d java.lang.ClassNotFoundException -> L40 java.lang.NoSuchMethodException -> L43
java.lang.Class<android.graphics.drawable.Drawable> r4 = android.graphics.drawable.Drawable.class
java.lang.String r5 = "getOpticalInsets"
java.lang.reflect.Method r4 = r4.getMethod(r5, r1) // Catch: java.lang.NoSuchFieldException -> L3d java.lang.ClassNotFoundException -> L40 java.lang.NoSuchMethodException -> L43
java.lang.String r5 = "left"
java.lang.reflect.Field r5 = r3.getField(r5) // Catch: java.lang.NoSuchFieldException -> L34 java.lang.ClassNotFoundException -> L37 java.lang.NoSuchMethodException -> L3a
java.lang.String r6 = "top"
java.lang.reflect.Field r6 = r3.getField(r6) // Catch: java.lang.NoSuchFieldException -> L2d java.lang.ClassNotFoundException -> L30 java.lang.NoSuchMethodException -> L32
java.lang.String r7 = "right"
java.lang.reflect.Field r7 = r3.getField(r7) // Catch: java.lang.Throwable -> L2b
java.lang.String r8 = "bottom"
java.lang.reflect.Field r3 = r3.getField(r8) // Catch: java.lang.Throwable -> L46
r8 = r0
goto L48
L2b:
r7 = r1
goto L46
L2d:
r6 = r1
L2e:
r7 = r6
goto L46
L30:
r6 = r1
goto L2e
L32:
r6 = r1
goto L2e
L34:
r5 = r1
L35:
r6 = r5
goto L2e
L37:
r5 = r1
L38:
r6 = r5
goto L2e
L3a:
r5 = r1
L3b:
r6 = r5
goto L2e
L3d:
r4 = r1
r5 = r4
goto L35
L40:
r4 = r1
r5 = r4
goto L38
L43:
r4 = r1
r5 = r4
goto L3b
L46:
r3 = r1
r8 = r2
L48:
if (r8 == 0) goto L57
androidx.appcompat.widget.DrawableUtils.Api18Impl.b = r4
androidx.appcompat.widget.DrawableUtils.Api18Impl.f293c = r5
androidx.appcompat.widget.DrawableUtils.Api18Impl.d = r6
androidx.appcompat.widget.DrawableUtils.Api18Impl.e = r7
androidx.appcompat.widget.DrawableUtils.Api18Impl.f = r3
androidx.appcompat.widget.DrawableUtils.Api18Impl.f292a = r0
goto L63
L57:
androidx.appcompat.widget.DrawableUtils.Api18Impl.b = r1
androidx.appcompat.widget.DrawableUtils.Api18Impl.f293c = r1
androidx.appcompat.widget.DrawableUtils.Api18Impl.d = r1
androidx.appcompat.widget.DrawableUtils.Api18Impl.e = r1
androidx.appcompat.widget.DrawableUtils.Api18Impl.f = r1
androidx.appcompat.widget.DrawableUtils.Api18Impl.f292a = r2
L63:
return
*/
throw new UnsupportedOperationException("Method not decompiled: androidx.appcompat.widget.DrawableUtils.Api18Impl.<clinit>():void");
}
}
@RequiresApi
/* loaded from: classes.dex */
public static class Api29Impl {
@DoNotInline
public static Insets a(Drawable drawable) {
return drawable.getOpticalInsets();
}
}
public static void a(Drawable drawable) {
String name = drawable.getClass().getName();
int i = Build.VERSION.SDK_INT;
if (i >= 29 && i < 31 && "android.graphics.drawable.ColorStateListDrawable".equals(name)) {
int[] state = drawable.getState();
if (state != null && state.length != 0) {
drawable.setState(b);
} else {
drawable.setState(f290a);
}
drawable.setState(state);
}
}
/* JADX WARN: Multi-variable type inference failed */
public static Rect b(Drawable drawable) {
int i;
int i2;
int i3;
int i4;
int i5 = Build.VERSION.SDK_INT;
if (i5 >= 29) {
Insets a2 = Api29Impl.a(drawable);
i = a2.left;
i2 = a2.top;
i3 = a2.right;
i4 = a2.bottom;
return new Rect(i, i2, i3, i4);
}
boolean z = drawable instanceof WrappedDrawable;
Drawable drawable2 = drawable;
if (z) {
drawable2 = ((WrappedDrawable) drawable).b();
}
if (i5 < 29) {
if (Api18Impl.f292a) {
try {
Object invoke = Api18Impl.b.invoke(drawable2, null);
if (invoke != null) {
return new Rect(Api18Impl.f293c.getInt(invoke), Api18Impl.d.getInt(invoke), Api18Impl.e.getInt(invoke), Api18Impl.f.getInt(invoke));
}
} catch (IllegalAccessException | InvocationTargetException unused) {
}
}
} else {
boolean z2 = Api18Impl.f292a;
}
return f291c;
}
public static PorterDuff.Mode c(int i, PorterDuff.Mode mode) {
if (i != 3) {
if (i != 5) {
if (i != 9) {
switch (i) {
case 14:
return PorterDuff.Mode.MULTIPLY;
case 15:
return PorterDuff.Mode.SCREEN;
case 16:
return PorterDuff.Mode.ADD;
default:
return mode;
}
}
return PorterDuff.Mode.SRC_ATOP;
}
return PorterDuff.Mode.SRC_IN;
}
return PorterDuff.Mode.SRC_OVER;
}
}