* 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>
251 lines
9.5 KiB
Java
251 lines
9.5 KiB
Java
package com.google.android.gms.internal.ads;
|
|
|
|
import android.content.Context;
|
|
import android.content.pm.PackageManager;
|
|
import android.content.res.AssetFileDescriptor;
|
|
import android.content.res.Resources;
|
|
import android.net.Uri;
|
|
import android.text.TextUtils;
|
|
import java.io.EOFException;
|
|
import java.io.FileInputStream;
|
|
import java.io.IOException;
|
|
import java.nio.channels.FileChannel;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public final class zzhx extends zzgt {
|
|
public final Context e;
|
|
public zzhf f;
|
|
public AssetFileDescriptor g;
|
|
public FileInputStream h;
|
|
public long i;
|
|
public boolean j;
|
|
|
|
public zzhx(Context context) {
|
|
super(false);
|
|
this.e = context.getApplicationContext();
|
|
}
|
|
|
|
@Override // com.google.android.gms.internal.ads.zzhb
|
|
public final long a(zzhf zzhfVar) {
|
|
String host;
|
|
Resources resourcesForApplication;
|
|
int parseInt;
|
|
Resources resources;
|
|
long j;
|
|
long min;
|
|
this.f = zzhfVar;
|
|
d(zzhfVar);
|
|
Uri uri = zzhfVar.f8483a;
|
|
long j2 = zzhfVar.f8484c;
|
|
Uri normalizeScheme = uri.normalizeScheme();
|
|
boolean equals = TextUtils.equals("rawresource", normalizeScheme.getScheme());
|
|
Context context = this.e;
|
|
if (equals) {
|
|
resources = context.getResources();
|
|
List<String> pathSegments = normalizeScheme.getPathSegments();
|
|
if (pathSegments.size() == 1) {
|
|
try {
|
|
parseInt = Integer.parseInt(pathSegments.get(0));
|
|
} catch (NumberFormatException unused) {
|
|
throw new zzhc("Resource identifier must be an integer.", null, 1004);
|
|
}
|
|
} else {
|
|
int size = pathSegments.size();
|
|
throw new zzhc(androidx.work.impl.workers.a.r(size, "rawresource:// URI must have exactly one path element, found ", new StringBuilder(String.valueOf(size).length() + 61)), null, 2000);
|
|
}
|
|
} else if (TextUtils.equals("android.resource", normalizeScheme.getScheme())) {
|
|
String path = normalizeScheme.getPath();
|
|
path.getClass();
|
|
if (path.startsWith("/")) {
|
|
path = path.substring(1);
|
|
}
|
|
if (TextUtils.isEmpty(normalizeScheme.getHost())) {
|
|
host = context.getPackageName();
|
|
} else {
|
|
host = normalizeScheme.getHost();
|
|
}
|
|
if (host.equals(context.getPackageName())) {
|
|
resourcesForApplication = context.getResources();
|
|
} else {
|
|
try {
|
|
resourcesForApplication = context.getPackageManager().getResourcesForApplication(host);
|
|
} catch (PackageManager.NameNotFoundException e) {
|
|
throw new zzhc("Package in android.resource:// URI not found. Check http://g.co/dev/packagevisibility.", e, 2005);
|
|
}
|
|
}
|
|
if (path.matches("\\d+")) {
|
|
try {
|
|
parseInt = Integer.parseInt(path);
|
|
} catch (NumberFormatException unused2) {
|
|
throw new zzhc("Resource identifier must be an integer.", null, 1004);
|
|
}
|
|
} else {
|
|
parseInt = resourcesForApplication.getIdentifier(android.support.v4.media.a.q(new StringBuilder(host.length() + 1 + path.length()), host, ":", path), "raw", null);
|
|
if (parseInt == 0) {
|
|
throw new zzhc("Resource not found.", null, 2005);
|
|
}
|
|
}
|
|
resources = resourcesForApplication;
|
|
} else {
|
|
String scheme = normalizeScheme.getScheme();
|
|
throw new zzhc(android.support.v4.media.a.q(new StringBuilder(String.valueOf(scheme).length() + 62), "Unsupported URI scheme (", scheme, "). Only android.resource is supported."), null, 1004);
|
|
}
|
|
try {
|
|
AssetFileDescriptor openRawResourceFd = resources.openRawResourceFd(parseInt);
|
|
if (openRawResourceFd != null) {
|
|
this.g = openRawResourceFd;
|
|
long length = openRawResourceFd.getLength();
|
|
FileInputStream fileInputStream = new FileInputStream(this.g.getFileDescriptor());
|
|
this.h = fileInputStream;
|
|
try {
|
|
if (length != -1 && j2 > length) {
|
|
throw new zzhc(null, null, 2008);
|
|
}
|
|
long startOffset = this.g.getStartOffset();
|
|
long skip = fileInputStream.skip(startOffset + j2) - startOffset;
|
|
if (skip == j2) {
|
|
if (length == -1) {
|
|
FileChannel channel = fileInputStream.getChannel();
|
|
if (channel.size() == 0) {
|
|
this.i = -1L;
|
|
j = -1;
|
|
} else {
|
|
j = channel.size() - channel.position();
|
|
this.i = j;
|
|
if (j < 0) {
|
|
throw new zzhc(null, null, 2008);
|
|
}
|
|
}
|
|
} else {
|
|
j = length - skip;
|
|
this.i = j;
|
|
if (j < 0) {
|
|
throw new zzhc();
|
|
}
|
|
}
|
|
long j3 = zzhfVar.d;
|
|
if (j3 != -1) {
|
|
if (j == -1) {
|
|
min = j3;
|
|
} else {
|
|
min = Math.min(j, j3);
|
|
}
|
|
this.i = min;
|
|
}
|
|
this.j = true;
|
|
e(zzhfVar);
|
|
if (j3 != -1) {
|
|
return j3;
|
|
}
|
|
return this.i;
|
|
}
|
|
throw new zzhc(null, null, 2008);
|
|
} catch (zzhw e2) {
|
|
throw e2;
|
|
} catch (IOException e3) {
|
|
throw new zzhc(null, e3, 2000);
|
|
}
|
|
}
|
|
throw new zzhc("Resource is compressed: ".concat(String.valueOf(normalizeScheme)), null, 2000);
|
|
} catch (Resources.NotFoundException e4) {
|
|
throw new zzhc(null, e4, 2005);
|
|
}
|
|
}
|
|
|
|
@Override // com.google.android.gms.internal.ads.zzj
|
|
public final int b(byte[] bArr, int i, int i2) {
|
|
if (i2 == 0) {
|
|
return 0;
|
|
}
|
|
long j = this.i;
|
|
if (j != 0) {
|
|
if (j != -1) {
|
|
try {
|
|
i2 = (int) Math.min(j, i2);
|
|
} catch (IOException e) {
|
|
throw new zzhc(null, e, 2000);
|
|
}
|
|
}
|
|
FileInputStream fileInputStream = this.h;
|
|
String str = zzfj.f7405a;
|
|
int read = fileInputStream.read(bArr, i, i2);
|
|
if (read == -1) {
|
|
if (this.i != -1) {
|
|
throw new zzhc("End of stream reached having not read sufficient data.", new EOFException(), 2000);
|
|
}
|
|
} else {
|
|
long j2 = this.i;
|
|
if (j2 != -1) {
|
|
this.i = j2 - read;
|
|
}
|
|
f(read);
|
|
return read;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // com.google.android.gms.internal.ads.zzhb
|
|
public final Uri zzc() {
|
|
zzhf zzhfVar = this.f;
|
|
if (zzhfVar != null) {
|
|
return zzhfVar.f8483a;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override // com.google.android.gms.internal.ads.zzhb
|
|
public final void zzd() {
|
|
this.f = null;
|
|
try {
|
|
try {
|
|
try {
|
|
FileInputStream fileInputStream = this.h;
|
|
if (fileInputStream != null) {
|
|
fileInputStream.close();
|
|
}
|
|
this.h = null;
|
|
try {
|
|
AssetFileDescriptor assetFileDescriptor = this.g;
|
|
if (assetFileDescriptor != null) {
|
|
assetFileDescriptor.close();
|
|
}
|
|
this.g = null;
|
|
if (this.j) {
|
|
this.j = false;
|
|
g();
|
|
}
|
|
} catch (IOException e) {
|
|
throw new zzhc(null, e, 2000);
|
|
}
|
|
} catch (IOException e2) {
|
|
throw new zzhc(null, e2, 2000);
|
|
}
|
|
} catch (Throwable th) {
|
|
this.h = null;
|
|
try {
|
|
AssetFileDescriptor assetFileDescriptor2 = this.g;
|
|
if (assetFileDescriptor2 != null) {
|
|
assetFileDescriptor2.close();
|
|
}
|
|
this.g = null;
|
|
if (this.j) {
|
|
this.j = false;
|
|
g();
|
|
}
|
|
throw th;
|
|
} catch (IOException e3) {
|
|
throw new zzhc(null, e3, 2000);
|
|
}
|
|
}
|
|
} catch (Throwable th2) {
|
|
this.g = null;
|
|
if (this.j) {
|
|
this.j = false;
|
|
g();
|
|
}
|
|
throw th2;
|
|
}
|
|
}
|
|
}
|