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

426 lines
17 KiB
Java

package com.google.android.gms.common.api;
import android.accounts.Account;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import androidx.annotation.MainThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
import androidx.core.content.ContextCompat;
import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
import com.google.android.gms.common.annotation.KeepForSdk;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.Api.ApiOptions;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.internal.ApiExceptionMapper;
import com.google.android.gms.common.api.internal.ApiKey;
import com.google.android.gms.common.api.internal.BaseImplementation;
import com.google.android.gms.common.api.internal.GoogleApiManager;
import com.google.android.gms.common.api.internal.ListenerHolder;
import com.google.android.gms.common.api.internal.ListenerHolders;
import com.google.android.gms.common.api.internal.NonGmsServiceBrokerClient;
import com.google.android.gms.common.api.internal.RegisterListenerMethod;
import com.google.android.gms.common.api.internal.RegistrationMethods;
import com.google.android.gms.common.api.internal.StatusExceptionMapper;
import com.google.android.gms.common.api.internal.TaskApiCall;
import com.google.android.gms.common.api.internal.UnregisterListenerMethod;
import com.google.android.gms.common.api.internal.zaab;
import com.google.android.gms.common.api.internal.zabk;
import com.google.android.gms.common.api.internal.zabq;
import com.google.android.gms.common.api.internal.zacm;
import com.google.android.gms.common.internal.BaseGmsClient;
import com.google.android.gms.common.internal.ClientSettings;
import com.google.android.gms.common.internal.Objects;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.wrappers.AttributionSourceWrapper;
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import java.util.Collection;
import java.util.Collections;
/* loaded from: classes.dex */
public abstract class GoogleApi<O extends Api.ApiOptions> implements HasApiKey<O> {
@NonNull
protected final GoogleApiManager zaa;
private final Context zab;
@Nullable
private final String zac;
@Nullable
private final AttributionSourceWrapper zad;
private final Api zae;
private final Api.ApiOptions zaf;
private final ApiKey zag;
private final Looper zah;
private final int zai;
private final GoogleApiClient zaj;
private final StatusExceptionMapper zak;
@KeepForSdk
/* loaded from: classes.dex */
public static class Settings {
@NonNull
@KeepForSdk
public static final Settings DEFAULT_SETTINGS = new Builder().build();
@NonNull
public final StatusExceptionMapper zaa;
@NonNull
public final Looper zab;
@KeepForSdk
/* loaded from: classes.dex */
public static class Builder {
private StatusExceptionMapper zaa;
private Looper zab;
@KeepForSdk
public Builder() {
}
/* JADX WARN: Multi-variable type inference failed */
@NonNull
@KeepForSdk
public Settings build() {
if (this.zaa == null) {
this.zaa = new ApiExceptionMapper();
}
if (this.zab == null) {
this.zab = Looper.getMainLooper();
}
return new Settings(this.zaa, null, this.zab, 0 == true ? 1 : 0);
}
@NonNull
@KeepForSdk
public Builder setLooper(@NonNull Looper looper) {
Preconditions.checkNotNull(looper, "Looper must not be null.");
this.zab = looper;
return this;
}
@NonNull
@KeepForSdk
public Builder setMapper(@NonNull StatusExceptionMapper statusExceptionMapper) {
Preconditions.checkNotNull(statusExceptionMapper, "StatusExceptionMapper must not be null.");
this.zaa = statusExceptionMapper;
return this;
}
}
@KeepForSdk
private Settings(StatusExceptionMapper statusExceptionMapper, Account account, Looper looper) {
this.zaa = statusExceptionMapper;
this.zab = looper;
}
public /* synthetic */ Settings(StatusExceptionMapper statusExceptionMapper, Account account, Looper looper, byte[] bArr) {
this(statusExceptionMapper, null, looper);
}
}
@KeepForSdk
@MainThread
public GoogleApi(@NonNull Activity activity, @NonNull Api<O> api, @NonNull O o, @NonNull Settings settings) {
this(activity, activity, api, o, settings);
}
private final BaseImplementation.ApiMethodImpl zad(int i, @NonNull BaseImplementation.ApiMethodImpl apiMethodImpl) {
apiMethodImpl.zak();
this.zaa.zak(this, i, apiMethodImpl);
return apiMethodImpl;
}
private final Task zae(int i, @NonNull TaskApiCall taskApiCall) {
TaskCompletionSource taskCompletionSource = new TaskCompletionSource();
this.zaa.zal(this, i, taskApiCall, taskCompletionSource, this.zak);
return taskCompletionSource.f11605a;
}
@NonNull
@KeepForSdk
public GoogleApiClient asGoogleApiClient() {
return this.zaj;
}
@NonNull
@KeepForSdk
public ClientSettings.Builder createClientSettingsBuilder() {
Collection collection;
GoogleSignInAccount googleSignInAccount;
ClientSettings.Builder builder = new ClientSettings.Builder();
Api.ApiOptions apiOptions = this.zaf;
boolean z = apiOptions instanceof Api.ApiOptions.HasGoogleSignInAccountOptions;
Account account = null;
if (z && (googleSignInAccount = ((Api.ApiOptions.HasGoogleSignInAccountOptions) apiOptions).getGoogleSignInAccount()) != null) {
String str = googleSignInAccount.g;
if (str != null) {
account = new Account(str, "com.google");
}
} else if (apiOptions instanceof Api.ApiOptions.HasAccountOptions) {
account = ((Api.ApiOptions.HasAccountOptions) apiOptions).getAccount();
}
builder.zaa(account);
if (z) {
GoogleSignInAccount googleSignInAccount2 = ((Api.ApiOptions.HasGoogleSignInAccountOptions) apiOptions).getGoogleSignInAccount();
if (googleSignInAccount2 == null) {
collection = Collections.EMPTY_SET;
} else {
collection = googleSignInAccount2.F();
}
} else {
collection = Collections.EMPTY_SET;
}
builder.zab(collection);
Context context = this.zab;
builder.zac(context.getClass().getName());
builder.setRealClientPackageName(context.getPackageName());
return builder;
}
@NonNull
@KeepForSdk
public Task<Boolean> disconnectService() {
return this.zaa.zaj(this);
}
@NonNull
@KeepForSdk
public <A extends Api.AnyClient, T extends BaseImplementation.ApiMethodImpl<? extends Result, A>> T doBestEffortWrite(@NonNull T t) {
zad(2, t);
return t;
}
@NonNull
@KeepForSdk
public <A extends Api.AnyClient, T extends BaseImplementation.ApiMethodImpl<? extends Result, A>> T doRead(@NonNull T t) {
zad(0, t);
return t;
}
@NonNull
@KeepForSdk
@Deprecated
public <A extends Api.AnyClient, T extends RegisterListenerMethod<A, ?>, U extends UnregisterListenerMethod<A, ?>> Task<Void> doRegisterEventListener(@NonNull T t, @NonNull U u) {
Preconditions.checkNotNull(t);
Preconditions.checkNotNull(u);
Preconditions.checkNotNull(t.getListenerKey(), "Listener has already been released.");
Preconditions.checkNotNull(u.getListenerKey(), "Listener has already been released.");
Preconditions.checkArgument(Objects.equal(t.getListenerKey(), u.getListenerKey()), "Listener registration and unregistration methods must be constructed with the same ListenerHolder.");
return this.zaa.zan(this, t, u, zab.zaa);
}
@NonNull
@KeepForSdk
public Task<Boolean> doUnregisterEventListener(@NonNull ListenerHolder.ListenerKey<?> listenerKey) {
return doUnregisterEventListener(listenerKey, 0);
}
@NonNull
@KeepForSdk
public <A extends Api.AnyClient, T extends BaseImplementation.ApiMethodImpl<? extends Result, A>> T doWrite(@NonNull T t) {
zad(1, t);
return t;
}
@Nullable
public String getApiFallbackAttributionTag(@NonNull Context context) {
return null;
}
@Override // com.google.android.gms.common.api.HasApiKey
@NonNull
public final ApiKey<O> getApiKey() {
return this.zag;
}
@NonNull
@KeepForSdk
public O getApiOptions() {
return (O) this.zaf;
}
@NonNull
@KeepForSdk
public Context getApplicationContext() {
return this.zab;
}
@Nullable
@KeepForSdk
public String getContextAttributionTag() {
return this.zac;
}
@Nullable
@KeepForSdk
@Deprecated
public String getContextFeatureId() {
return this.zac;
}
@NonNull
@KeepForSdk
public Looper getLooper() {
return this.zah;
}
@NonNull
@KeepForSdk
public <L> ListenerHolder<L> registerListener(@NonNull L l, @NonNull String str) {
return ListenerHolders.createListenerHolder(l, this.zah, str);
}
/* JADX WARN: Multi-variable type inference failed */
@WorkerThread
public final Api.Client zaa(Looper looper, zabk zabkVar) {
ClientSettings build = createClientSettingsBuilder().build();
Api.Client buildClient = ((Api.AbstractClientBuilder) Preconditions.checkNotNull(this.zae.zab())).buildClient(this.zab, looper, build, (ClientSettings) this.zaf, (GoogleApiClient.ConnectionCallbacks) zabkVar, (GoogleApiClient.OnConnectionFailedListener) zabkVar);
AttributionSourceWrapper attributionSourceWrapper = this.zad;
if (attributionSourceWrapper != null && (buildClient instanceof BaseGmsClient)) {
((BaseGmsClient) buildClient).setAttributionSourceWrapper(attributionSourceWrapper);
return buildClient;
}
if (attributionSourceWrapper != null && (buildClient instanceof NonGmsServiceBrokerClient)) {
((NonGmsServiceBrokerClient) buildClient).zab(attributionSourceWrapper);
return buildClient;
}
String contextAttributionTag = getContextAttributionTag();
if (contextAttributionTag != null && (buildClient instanceof BaseGmsClient)) {
((BaseGmsClient) buildClient).setAttributionTag(contextAttributionTag);
}
if (contextAttributionTag != null && (buildClient instanceof NonGmsServiceBrokerClient)) {
((NonGmsServiceBrokerClient) buildClient).zaa(contextAttributionTag);
}
return buildClient;
}
public final int zab() {
return this.zai;
}
public final zacm zac(Context context, Handler handler) {
return new zacm(context, handler, createClientSettingsBuilder().build());
}
/* JADX WARN: Illegal instructions before constructor call */
@com.google.android.gms.common.annotation.KeepForSdk
@java.lang.Deprecated
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public GoogleApi(@androidx.annotation.NonNull android.app.Activity r2, @androidx.annotation.NonNull com.google.android.gms.common.api.Api<O> r3, @androidx.annotation.NonNull O r4, @androidx.annotation.NonNull com.google.android.gms.common.api.internal.StatusExceptionMapper r5) {
/*
r1 = this;
com.google.android.gms.common.api.GoogleApi$Settings$Builder r0 = new com.google.android.gms.common.api.GoogleApi$Settings$Builder
r0.<init>()
r0.setMapper(r5)
android.os.Looper r5 = r2.getMainLooper()
r0.setLooper(r5)
com.google.android.gms.common.api.GoogleApi$Settings r5 = r0.build()
r1.<init>(r2, r3, r4, r5)
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.api.GoogleApi.<init>(android.app.Activity, com.google.android.gms.common.api.Api, com.google.android.gms.common.api.Api$ApiOptions, com.google.android.gms.common.api.internal.StatusExceptionMapper):void");
}
@NonNull
@KeepForSdk
public <TResult, A extends Api.AnyClient> Task<TResult> doBestEffortWrite(@NonNull TaskApiCall<A, TResult> taskApiCall) {
return zae(2, taskApiCall);
}
@NonNull
@KeepForSdk
public <TResult, A extends Api.AnyClient> Task<TResult> doRead(@NonNull TaskApiCall<A, TResult> taskApiCall) {
return zae(0, taskApiCall);
}
@NonNull
@KeepForSdk
public Task<Boolean> doUnregisterEventListener(@NonNull ListenerHolder.ListenerKey<?> listenerKey, int i) {
Preconditions.checkNotNull(listenerKey, "Listener key cannot be null.");
return this.zaa.zao(this, listenerKey, i);
}
@NonNull
@KeepForSdk
public <TResult, A extends Api.AnyClient> Task<TResult> doWrite(@NonNull TaskApiCall<A, TResult> taskApiCall) {
return zae(1, taskApiCall);
}
private GoogleApi(@NonNull Context context, @Nullable Activity activity, Api api, Api.ApiOptions apiOptions, Settings settings) {
String apiFallbackAttributionTag;
Preconditions.checkNotNull(context, "Null context is not permitted.");
Preconditions.checkNotNull(api, "Api must not be null.");
Preconditions.checkNotNull(settings, "Settings must not be null; use Settings.DEFAULT_SETTINGS instead.");
Context context2 = (Context) Preconditions.checkNotNull(context.getApplicationContext(), "The provided context did not have an application context.");
this.zab = context2;
int i = Build.VERSION.SDK_INT;
if (i >= 30) {
apiFallbackAttributionTag = ContextCompat.b(context);
} else {
apiFallbackAttributionTag = getApiFallbackAttributionTag(context);
}
this.zac = apiFallbackAttributionTag;
this.zad = i >= 31 ? new AttributionSourceWrapper(context.getAttributionSource()) : null;
this.zae = api;
this.zaf = apiOptions;
this.zah = settings.zab;
ApiKey sharedApiKey = ApiKey.getSharedApiKey(api, apiOptions, apiFallbackAttributionTag);
this.zag = sharedApiKey;
this.zaj = new zabq(this);
GoogleApiManager zaa = GoogleApiManager.zaa(context2);
this.zaa = zaa;
this.zai = zaa.zac();
this.zak = settings.zaa;
if (activity != null && !(activity instanceof GoogleApiActivity) && Looper.myLooper() == Looper.getMainLooper()) {
zaab.zaa(activity, zaa, sharedApiKey);
}
zaa.zad(this);
}
@NonNull
@KeepForSdk
public <A extends Api.AnyClient> Task<Void> doRegisterEventListener(@NonNull RegistrationMethods<A, ?> registrationMethods) {
Preconditions.checkNotNull(registrationMethods);
Preconditions.checkNotNull(registrationMethods.register.getListenerKey(), "Listener has already been released.");
UnregisterListenerMethod unregisterListenerMethod = registrationMethods.zaa;
Preconditions.checkNotNull(unregisterListenerMethod.getListenerKey(), "Listener has already been released.");
return this.zaa.zan(this, registrationMethods.register, unregisterListenerMethod, registrationMethods.zab);
}
@KeepForSdk
public GoogleApi(@NonNull Context context, @NonNull Api<O> api, @NonNull O o, @NonNull Settings settings) {
this(context, null, api, o, settings);
}
/* JADX WARN: Illegal instructions before constructor call */
@com.google.android.gms.common.annotation.KeepForSdk
@java.lang.Deprecated
/*
Code decompiled incorrectly, please refer to instructions dump.
To view partially-correct add '--show-bad-code' argument
*/
public GoogleApi(@androidx.annotation.NonNull android.content.Context r2, @androidx.annotation.NonNull com.google.android.gms.common.api.Api<O> r3, @androidx.annotation.NonNull O r4, @androidx.annotation.NonNull com.google.android.gms.common.api.internal.StatusExceptionMapper r5) {
/*
r1 = this;
com.google.android.gms.common.api.GoogleApi$Settings$Builder r0 = new com.google.android.gms.common.api.GoogleApi$Settings$Builder
r0.<init>()
r0.setMapper(r5)
com.google.android.gms.common.api.GoogleApi$Settings r5 = r0.build()
r1.<init>(r2, r3, r4, r5)
return
*/
throw new UnsupportedOperationException("Method not decompiled: com.google.android.gms.common.api.GoogleApi.<init>(android.content.Context, com.google.android.gms.common.api.Api, com.google.android.gms.common.api.Api$ApiOptions, com.google.android.gms.common.api.internal.StatusExceptionMapper):void");
}
}