soul-browser/sources/java/com/google/android/gms/common/images/ImageManager.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

178 lines
6.1 KiB
Java

package com.google.android.gms.common.images;
import android.app.BroadcastOptions;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.os.ResultReceiver;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.LruCache;
import com.google.android.gms.common.annotation.KeepName;
import com.google.android.gms.common.internal.Asserts;
import com.google.android.gms.common.internal.Constants;
import com.google.android.gms.internal.base.zaj;
import com.google.android.gms.internal.base.zan;
import com.google.android.gms.internal.base.zao;
import j$.util.Objects;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ExecutorService;
/* loaded from: classes.dex */
public final class ImageManager {
private static final Object zaa = new Object();
private static final HashSet zab = new HashSet();
private static ImageManager zac;
private final Context zad;
private final Handler zae = new zao(Looper.getMainLooper());
private final ExecutorService zaf = zan.b.zaa();
private final zaj zag = new LruCache(10);
private final Map zah = new HashMap();
private final Map zai = new HashMap();
private final Map zaj = new HashMap();
@KeepName
/* loaded from: classes.dex */
public final class ImageReceiver extends ResultReceiver {
final /* synthetic */ ImageManager zaa;
private final Uri zab;
private final ArrayList zac;
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public ImageReceiver(ImageManager imageManager, Uri uri) {
super(new zao(Looper.getMainLooper()));
Objects.requireNonNull(imageManager);
this.zaa = imageManager;
this.zab = uri;
this.zac = new ArrayList();
}
@Override // android.os.ResultReceiver
public final void onReceiveResult(int i, Bundle bundle) {
AssetFileDescriptor assetFileDescriptor;
ParcelFileDescriptor parcelFileDescriptor = (ParcelFileDescriptor) bundle.getParcelable("com.google.android.gms.extra.fileDescriptor");
if (parcelFileDescriptor != null) {
assetFileDescriptor = new AssetFileDescriptor(parcelFileDescriptor, bundle.getLong("assetFdStartOffset", 0L), bundle.getLong("assetFdLength", -1L));
} else {
assetFileDescriptor = null;
}
ImageManager imageManager = this.zaa;
imageManager.zaf().execute(new zaa(imageManager, this.zab, assetFileDescriptor));
}
public final void zaa(zag zagVar) {
Asserts.checkMainThread("ImageReceiver.addImageRequest() must be called in the main thread");
this.zac.add(zagVar);
}
public final void zab(zag zagVar) {
Asserts.checkMainThread("ImageReceiver.removeImageRequest() must be called in the main thread");
this.zac.remove(zagVar);
}
public final void zac() {
Intent intent = new Intent(Constants.ACTION_LOAD_IMAGE);
intent.setPackage("com.google.android.gms");
intent.putExtra(Constants.EXTRA_URI, this.zab);
intent.putExtra(Constants.EXTRA_RESULT_RECEIVER, this);
intent.putExtra(Constants.EXTRA_PRIORITY, 3);
int i = Build.VERSION.SDK_INT;
Context zad = this.zaa.zad();
if (i < 34) {
zad.sendBroadcast(intent);
} else {
zad.sendBroadcast(intent, null, BroadcastOptions.makeBasic().setShareIdentityEnabled(true).toBundle());
}
}
public final /* synthetic */ ArrayList zad() {
return this.zac;
}
}
/* loaded from: classes.dex */
public interface OnImageLoadedListener {
void onImageLoaded(@NonNull Uri uri, @Nullable Drawable drawable, boolean z);
}
/* JADX WARN: Type inference failed for: r1v5, types: [androidx.collection.LruCache, com.google.android.gms.internal.base.zaj] */
private ImageManager(Context context, boolean z) {
this.zad = context.getApplicationContext();
}
@NonNull
public static ImageManager create(@NonNull Context context) {
if (zac == null) {
zac = new ImageManager(context, false);
}
return zac;
}
public void loadImage(@NonNull ImageView imageView, int i) {
zaa(new zae(imageView, i));
}
public final void zaa(zag zagVar) {
Asserts.checkMainThread("ImageManager.loadImage() must be called in the main thread");
new zab(this, zagVar).run();
}
public final /* synthetic */ Context zad() {
return this.zad;
}
public final /* synthetic */ Handler zae() {
return this.zae;
}
public final /* synthetic */ ExecutorService zaf() {
return this.zaf;
}
public final /* synthetic */ zaj zag() {
return this.zag;
}
public final /* synthetic */ Map zah() {
return this.zah;
}
public final /* synthetic */ Map zai() {
return this.zai;
}
public final /* synthetic */ Map zaj() {
return this.zaj;
}
public void loadImage(@NonNull ImageView imageView, @NonNull Uri uri) {
zaa(new zae(imageView, uri));
}
public void loadImage(@NonNull ImageView imageView, @NonNull Uri uri, int i) {
zae zaeVar = new zae(imageView, uri);
zaeVar.zab = i;
zaa(zaeVar);
}
public void loadImage(@NonNull OnImageLoadedListener onImageLoadedListener, @NonNull Uri uri) {
zaa(new zaf(onImageLoadedListener, uri));
}
public void loadImage(@NonNull OnImageLoadedListener onImageLoadedListener, @NonNull Uri uri, int i) {
zaf zafVar = new zaf(onImageLoadedListener, uri);
zafVar.zab = i;
zaa(zafVar);
}
}