* 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>
360 lines
14 KiB
Java
360 lines
14 KiB
Java
package androidx.core.content;
|
|
|
|
import android.content.ContentProvider;
|
|
import android.content.ContentValues;
|
|
import android.content.Context;
|
|
import android.content.pm.ProviderInfo;
|
|
import android.content.res.XmlResourceParser;
|
|
import android.database.Cursor;
|
|
import android.database.MatrixCursor;
|
|
import android.net.Uri;
|
|
import android.os.Environment;
|
|
import android.os.ParcelFileDescriptor;
|
|
import android.support.v4.media.a;
|
|
import android.text.TextUtils;
|
|
import android.webkit.MimeTypeMap;
|
|
import androidx.annotation.RequiresApi;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
import java.util.Map;
|
|
import kotlin.uuid.Uuid;
|
|
import org.xmlpull.v1.XmlPullParserException;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class FileProvider extends ContentProvider {
|
|
public static final String[] h = {"_display_name", "_size"};
|
|
public static final File i = new File("/");
|
|
public static final HashMap j = new HashMap();
|
|
|
|
/* renamed from: c, reason: collision with root package name */
|
|
public final Object f651c = new Object();
|
|
public String f;
|
|
public PathStrategy g;
|
|
|
|
@RequiresApi
|
|
/* loaded from: classes.dex */
|
|
public static class Api21Impl {
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public interface PathStrategy {
|
|
File a(Uri uri);
|
|
|
|
Uri b(File file);
|
|
}
|
|
|
|
/* loaded from: classes.dex */
|
|
public static class SimplePathStrategy implements PathStrategy {
|
|
|
|
/* renamed from: a, reason: collision with root package name */
|
|
public final String f652a;
|
|
public final HashMap b = new HashMap();
|
|
|
|
public SimplePathStrategy(String str) {
|
|
this.f652a = str;
|
|
}
|
|
|
|
public static boolean c(String str, String str2) {
|
|
String a2 = FileProvider.a(str);
|
|
String a3 = FileProvider.a(str2);
|
|
if (!a2.equals(a3)) {
|
|
if (!a2.startsWith(a3 + '/')) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // androidx.core.content.FileProvider.PathStrategy
|
|
public final File a(Uri uri) {
|
|
String encodedPath = uri.getEncodedPath();
|
|
int indexOf = encodedPath.indexOf(47, 1);
|
|
String decode = Uri.decode(encodedPath.substring(1, indexOf));
|
|
String decode2 = Uri.decode(encodedPath.substring(indexOf + 1));
|
|
File file = (File) this.b.get(decode);
|
|
if (file != null) {
|
|
File file2 = new File(file, decode2);
|
|
try {
|
|
File canonicalFile = file2.getCanonicalFile();
|
|
if (c(canonicalFile.getPath(), file.getPath())) {
|
|
return canonicalFile;
|
|
}
|
|
throw new SecurityException("Resolved path jumped beyond configured root");
|
|
} catch (IOException unused) {
|
|
throw new IllegalArgumentException("Failed to resolve canonical path for " + file2);
|
|
}
|
|
}
|
|
throw new IllegalArgumentException("Unable to find configured root for " + uri);
|
|
}
|
|
|
|
@Override // androidx.core.content.FileProvider.PathStrategy
|
|
public final Uri b(File file) {
|
|
String substring;
|
|
try {
|
|
String canonicalPath = file.getCanonicalPath();
|
|
Map.Entry entry = null;
|
|
for (Map.Entry entry2 : this.b.entrySet()) {
|
|
String path = ((File) entry2.getValue()).getPath();
|
|
if (c(canonicalPath, path) && (entry == null || path.length() > ((File) entry.getValue()).getPath().length())) {
|
|
entry = entry2;
|
|
}
|
|
}
|
|
if (entry != null) {
|
|
String path2 = ((File) entry.getValue()).getPath();
|
|
if (path2.endsWith("/")) {
|
|
substring = canonicalPath.substring(path2.length());
|
|
} else {
|
|
substring = canonicalPath.substring(path2.length() + 1);
|
|
}
|
|
return new Uri.Builder().scheme("content").authority(this.f652a).encodedPath(Uri.encode((String) entry.getKey()) + '/' + Uri.encode(substring, "/")).build();
|
|
}
|
|
throw new IllegalArgumentException(a.C("Failed to find configured root that contains ", canonicalPath));
|
|
} catch (IOException unused) {
|
|
throw new IllegalArgumentException("Failed to resolve canonical path for " + file);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static String a(String str) {
|
|
if (str.length() > 0 && str.charAt(str.length() - 1) == '/') {
|
|
return a.d(1, 0, str);
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public static PathStrategy c(Context context, String str) {
|
|
PathStrategy pathStrategy;
|
|
HashMap hashMap = j;
|
|
synchronized (hashMap) {
|
|
try {
|
|
pathStrategy = (PathStrategy) hashMap.get(str);
|
|
if (pathStrategy == null) {
|
|
try {
|
|
try {
|
|
pathStrategy = e(context, str);
|
|
hashMap.put(str, pathStrategy);
|
|
} catch (IOException e) {
|
|
throw new IllegalArgumentException("Failed to parse android.support.FILE_PROVIDER_PATHS meta-data", e);
|
|
}
|
|
} catch (XmlPullParserException e2) {
|
|
throw new IllegalArgumentException("Failed to parse android.support.FILE_PROVIDER_PATHS meta-data", e2);
|
|
}
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return pathStrategy;
|
|
}
|
|
|
|
public static Uri d(Context context, String str, File file) {
|
|
return c(context, str).b(file);
|
|
}
|
|
|
|
public static SimplePathStrategy e(Context context, String str) {
|
|
SimplePathStrategy simplePathStrategy = new SimplePathStrategy(str);
|
|
ProviderInfo resolveContentProvider = context.getPackageManager().resolveContentProvider(str, Uuid.SIZE_BITS);
|
|
if (resolveContentProvider != null) {
|
|
XmlResourceParser loadXmlMetaData = resolveContentProvider.loadXmlMetaData(context.getPackageManager(), "android.support.FILE_PROVIDER_PATHS");
|
|
if (loadXmlMetaData == null) {
|
|
throw new IllegalArgumentException("Missing android.support.FILE_PROVIDER_PATHS meta-data");
|
|
}
|
|
while (true) {
|
|
int next = loadXmlMetaData.next();
|
|
if (next != 1) {
|
|
if (next == 2) {
|
|
String name = loadXmlMetaData.getName();
|
|
File file = null;
|
|
String attributeValue = loadXmlMetaData.getAttributeValue(null, "name");
|
|
String attributeValue2 = loadXmlMetaData.getAttributeValue(null, "path");
|
|
if ("root-path".equals(name)) {
|
|
file = i;
|
|
} else if ("files-path".equals(name)) {
|
|
file = context.getFilesDir();
|
|
} else if ("cache-path".equals(name)) {
|
|
file = context.getCacheDir();
|
|
} else if ("external-path".equals(name)) {
|
|
file = Environment.getExternalStorageDirectory();
|
|
} else if ("external-files-path".equals(name)) {
|
|
File[] externalFilesDirs = context.getExternalFilesDirs(null);
|
|
if (externalFilesDirs.length > 0) {
|
|
file = externalFilesDirs[0];
|
|
}
|
|
} else if ("external-cache-path".equals(name)) {
|
|
File[] externalCacheDirs = context.getExternalCacheDirs();
|
|
if (externalCacheDirs.length > 0) {
|
|
file = externalCacheDirs[0];
|
|
}
|
|
} else if ("external-media-path".equals(name)) {
|
|
File[] externalMediaDirs = context.getExternalMediaDirs();
|
|
if (externalMediaDirs.length > 0) {
|
|
file = externalMediaDirs[0];
|
|
}
|
|
}
|
|
if (file == null) {
|
|
continue;
|
|
} else {
|
|
String str2 = new String[]{attributeValue2}[0];
|
|
if (str2 != null) {
|
|
file = new File(file, str2);
|
|
}
|
|
if (!TextUtils.isEmpty(attributeValue)) {
|
|
try {
|
|
simplePathStrategy.b.put(attributeValue, file.getCanonicalFile());
|
|
} catch (IOException e) {
|
|
throw new IllegalArgumentException("Failed to resolve canonical path for " + file, e);
|
|
}
|
|
} else {
|
|
throw new IllegalArgumentException("Name must not be empty");
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
return simplePathStrategy;
|
|
}
|
|
}
|
|
} else {
|
|
throw new IllegalArgumentException(a.C("Couldn't find meta-data for provider with authority ", str));
|
|
}
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final void attachInfo(Context context, ProviderInfo providerInfo) {
|
|
super.attachInfo(context, providerInfo);
|
|
if (!providerInfo.exported) {
|
|
if (providerInfo.grantUriPermissions) {
|
|
String str = providerInfo.authority.split(";")[0];
|
|
synchronized (this.f651c) {
|
|
this.f = str;
|
|
}
|
|
HashMap hashMap = j;
|
|
synchronized (hashMap) {
|
|
hashMap.remove(str);
|
|
}
|
|
return;
|
|
}
|
|
throw new SecurityException("Provider must grant uri permissions");
|
|
}
|
|
throw new SecurityException("Provider must not be exported");
|
|
}
|
|
|
|
public final PathStrategy b() {
|
|
PathStrategy pathStrategy;
|
|
synchronized (this.f651c) {
|
|
try {
|
|
if (this.f != null) {
|
|
if (this.g == null) {
|
|
this.g = c(getContext(), this.f);
|
|
}
|
|
pathStrategy = this.g;
|
|
} else {
|
|
throw new NullPointerException("mAuthority is null. Did you override attachInfo and did not call super.attachInfo()?");
|
|
}
|
|
} catch (Throwable th) {
|
|
throw th;
|
|
}
|
|
}
|
|
return pathStrategy;
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final int delete(Uri uri, String str, String[] strArr) {
|
|
return b().a(uri).delete() ? 1 : 0;
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final String getType(Uri uri) {
|
|
File a2 = b().a(uri);
|
|
int lastIndexOf = a2.getName().lastIndexOf(46);
|
|
if (lastIndexOf >= 0) {
|
|
String mimeTypeFromExtension = MimeTypeMap.getSingleton().getMimeTypeFromExtension(a2.getName().substring(lastIndexOf + 1));
|
|
if (mimeTypeFromExtension != null) {
|
|
return mimeTypeFromExtension;
|
|
}
|
|
return "application/octet-stream";
|
|
}
|
|
return "application/octet-stream";
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final String getTypeAnonymous(Uri uri) {
|
|
return "application/octet-stream";
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final Uri insert(Uri uri, ContentValues contentValues) {
|
|
throw new UnsupportedOperationException("No external inserts");
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final boolean onCreate() {
|
|
return true;
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final ParcelFileDescriptor openFile(Uri uri, String str) {
|
|
int i2;
|
|
File a2 = b().a(uri);
|
|
if ("r".equals(str)) {
|
|
i2 = 268435456;
|
|
} else if (!"w".equals(str) && !"wt".equals(str)) {
|
|
if ("wa".equals(str)) {
|
|
i2 = 704643072;
|
|
} else if ("rw".equals(str)) {
|
|
i2 = 939524096;
|
|
} else if ("rwt".equals(str)) {
|
|
i2 = 1006632960;
|
|
} else {
|
|
throw new IllegalArgumentException(a.C("Invalid mode: ", str));
|
|
}
|
|
} else {
|
|
i2 = 738197504;
|
|
}
|
|
return ParcelFileDescriptor.open(a2, i2);
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final Cursor query(Uri uri, String[] strArr, String str, String[] strArr2, String str2) {
|
|
int i2;
|
|
String str3;
|
|
File a2 = b().a(uri);
|
|
String queryParameter = uri.getQueryParameter("displayName");
|
|
if (strArr == null) {
|
|
strArr = h;
|
|
}
|
|
String[] strArr3 = new String[strArr.length];
|
|
Object[] objArr = new Object[strArr.length];
|
|
int i3 = 0;
|
|
for (String str4 : strArr) {
|
|
if ("_display_name".equals(str4)) {
|
|
strArr3[i3] = "_display_name";
|
|
i2 = i3 + 1;
|
|
if (queryParameter == null) {
|
|
str3 = a2.getName();
|
|
} else {
|
|
str3 = queryParameter;
|
|
}
|
|
objArr[i3] = str3;
|
|
} else if ("_size".equals(str4)) {
|
|
strArr3[i3] = "_size";
|
|
i2 = i3 + 1;
|
|
objArr[i3] = Long.valueOf(a2.length());
|
|
}
|
|
i3 = i2;
|
|
}
|
|
String[] strArr4 = new String[i3];
|
|
System.arraycopy(strArr3, 0, strArr4, 0, i3);
|
|
Object[] objArr2 = new Object[i3];
|
|
System.arraycopy(objArr, 0, objArr2, 0, i3);
|
|
MatrixCursor matrixCursor = new MatrixCursor(strArr4, 1);
|
|
matrixCursor.addRow(objArr2);
|
|
return matrixCursor;
|
|
}
|
|
|
|
@Override // android.content.ContentProvider
|
|
public final int update(Uri uri, ContentValues contentValues, String str, String[] strArr) {
|
|
throw new UnsupportedOperationException("No external updates");
|
|
}
|
|
}
|