soul-browser/sources/java/androidx/browser/customtabs/CustomTabsClient.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

265 lines
11 KiB
Java

package androidx.browser.customtabs;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
import android.support.customtabs.IAuthTabCallback;
import android.support.customtabs.ICustomTabsCallback;
import android.support.customtabs.ICustomTabsService;
import android.util.Log;
import java.util.ArrayList;
/* loaded from: classes.dex */
public class CustomTabsClient {
/* renamed from: a, reason: collision with root package name */
public final ICustomTabsService f409a;
public final ComponentName b;
/* renamed from: androidx.browser.customtabs.CustomTabsClient$1, reason: invalid class name */
/* loaded from: classes.dex */
class AnonymousClass1 extends CustomTabsServiceConnection {
@Override // androidx.browser.customtabs.CustomTabsServiceConnection
public final void a(CustomTabsClient customTabsClient) {
try {
customTabsClient.f409a.warmup(0L);
} catch (RemoteException unused) {
}
throw null;
}
@Override // android.content.ServiceConnection
public final void onServiceDisconnected(ComponentName componentName) {
}
}
/* renamed from: androidx.browser.customtabs.CustomTabsClient$2, reason: invalid class name */
/* loaded from: classes.dex */
class AnonymousClass2 extends IAuthTabCallback.Stub {
@Override // android.support.customtabs.IAuthTabCallback
public final void onExtraCallback(String str, Bundle bundle) {
}
@Override // android.support.customtabs.IAuthTabCallback
public final Bundle onExtraCallbackWithResult(String str, Bundle bundle) {
return Bundle.EMPTY;
}
@Override // android.support.customtabs.IAuthTabCallback
public final void onNavigationEvent(int i, Bundle bundle) {
}
@Override // android.support.customtabs.IAuthTabCallback
public final void onWarmupCompleted(Bundle bundle) {
}
}
public CustomTabsClient(ICustomTabsService iCustomTabsService, ComponentName componentName) {
this.f409a = iCustomTabsService;
this.b = componentName;
}
public static void a(Context context, String str, CustomTabsServiceConnection customTabsServiceConnection) {
customTabsServiceConnection.f424c = context.getApplicationContext();
Intent intent = new Intent("android.support.customtabs.action.CustomTabsService");
if (!str.isEmpty()) {
intent.setPackage(str);
context.bindService(intent, customTabsServiceConnection, 33);
return;
}
throw new IllegalArgumentException("Service Intents must be explicit");
}
public static String b(Context context) {
PackageManager packageManager = context.getPackageManager();
ArrayList arrayList = new ArrayList();
ResolveInfo resolveActivity = packageManager.resolveActivity(new Intent("android.intent.action.VIEW", Uri.parse("http://")), 0);
if (resolveActivity != null) {
String str = resolveActivity.activityInfo.packageName;
ArrayList arrayList2 = new ArrayList(arrayList.size() + 1);
arrayList2.add(str);
arrayList = arrayList2;
}
Intent intent = new Intent("android.support.customtabs.action.CustomTabsService");
int size = arrayList.size();
int i = 0;
while (i < size) {
Object obj = arrayList.get(i);
i++;
String str2 = (String) obj;
intent.setPackage(str2);
if (packageManager.resolveService(intent, 0) != null) {
return str2;
}
}
if (Build.VERSION.SDK_INT >= 30) {
Log.w("CustomTabsClient", "Unable to find any Custom Tabs packages, you may need to add a <queries> element to your manifest. See the docs for CustomTabsClient#getPackageName.");
return null;
}
return null;
}
public final CustomTabsSession c(final CustomTabsCallback customTabsCallback) {
ICustomTabsService iCustomTabsService = this.f409a;
ICustomTabsCallback.Stub stub = new ICustomTabsCallback.Stub() { // from class: androidx.browser.customtabs.CustomTabsClient.3
/* renamed from: c, reason: collision with root package name */
public final Handler f410c = new Handler(Looper.getMainLooper());
@Override // android.support.customtabs.ICustomTabsCallback
public final void extraCallback(final String str, final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.2
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.a(str, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final Bundle extraCallbackWithResult(String str, Bundle bundle) {
CustomTabsCallback customTabsCallback2 = CustomTabsCallback.this;
if (customTabsCallback2 == null) {
return null;
}
return customTabsCallback2.b(str, bundle);
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onActivityLayout(final int i, final int i2, final int i3, final int i4, final int i5, final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.8
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.c(i, i2, i3, i4, i5, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onActivityResized(final int i, final int i2, final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.6
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.d(i, i2, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onMessageChannelReady(final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.3
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.e(bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onMinimized(final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.9
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.f(bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onNavigationEvent(final int i, final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.1
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.g(i, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onPostMessage(final String str, final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.4
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.h(str, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onRelationshipValidationResult(final int i, final Uri uri, final boolean z, final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.5
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.i(i, uri, z, bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onUnminimized(final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.10
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.j(bundle);
}
});
}
@Override // android.support.customtabs.ICustomTabsCallback
public final void onWarmupCompleted(final Bundle bundle) {
if (CustomTabsCallback.this == null) {
return;
}
this.f410c.post(new Runnable() { // from class: androidx.browser.customtabs.CustomTabsClient.3.7
@Override // java.lang.Runnable
public final void run() {
CustomTabsCallback.this.k(bundle);
}
});
}
};
try {
if (!iCustomTabsService.newSession(stub)) {
return null;
}
return new CustomTabsSession(iCustomTabsService, stub, this.b);
} catch (RemoteException unused) {
return null;
}
}
}