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

260 lines
10 KiB
Java

package com.google.android.gms.common.internal;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.work.impl.workers.a;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
/* loaded from: classes.dex */
public final class zak implements Handler.Callback {
private final zaj zab;
private final Handler zah;
private final ArrayList zac = new ArrayList();
@VisibleForTesting
final ArrayList zaa = new ArrayList();
private final ArrayList zad = new ArrayList();
private volatile boolean zae = false;
private final AtomicInteger zaf = new AtomicInteger(0);
private boolean zag = false;
private final Object zai = new Object();
public zak(Looper looper, zaj zajVar) {
this.zab = zajVar;
this.zah = new com.google.android.gms.internal.base.zao(looper, this);
}
@Override // android.os.Handler.Callback
public final boolean handleMessage(Message message) {
int i = message.what;
if (i == 1) {
GoogleApiClient.ConnectionCallbacks connectionCallbacks = (GoogleApiClient.ConnectionCallbacks) message.obj;
synchronized (this.zai) {
try {
if (this.zae && this.zab.isConnected() && this.zac.contains(connectionCallbacks)) {
connectionCallbacks.onConnected(null);
}
} catch (Throwable th) {
throw th;
}
}
return true;
}
Log.wtf("GmsClientEvents", a.r(i, "Don't know how to handle message: ", new StringBuilder(String.valueOf(i).length() + 34)), new Exception());
return false;
}
public final void zaa() {
this.zae = false;
this.zaf.incrementAndGet();
}
public final void zab() {
this.zae = true;
}
@VisibleForTesting
public final void zac(@Nullable Bundle bundle) {
Handler handler = this.zah;
Preconditions.checkHandlerThread(handler, "onConnectionSuccess must only be called on the Handler thread");
synchronized (this.zai) {
try {
Preconditions.checkState(!this.zag);
handler.removeMessages(1);
this.zag = true;
ArrayList arrayList = this.zaa;
Preconditions.checkState(arrayList.isEmpty());
ArrayList arrayList2 = new ArrayList(this.zac);
AtomicInteger atomicInteger = this.zaf;
int i = atomicInteger.get();
int size = arrayList2.size();
int i2 = 0;
while (i2 < size) {
Object obj = arrayList2.get(i2);
i2++;
GoogleApiClient.ConnectionCallbacks connectionCallbacks = (GoogleApiClient.ConnectionCallbacks) obj;
if (!this.zae || !this.zab.isConnected() || atomicInteger.get() != i) {
break;
} else if (!arrayList.contains(connectionCallbacks)) {
connectionCallbacks.onConnected(bundle);
}
}
arrayList.clear();
this.zag = false;
} catch (Throwable th) {
throw th;
}
}
}
@VisibleForTesting
public final void zad(int i) {
Handler handler = this.zah;
Preconditions.checkHandlerThread(handler, "onUnintentionalDisconnection must only be called on the Handler thread");
handler.removeMessages(1);
synchronized (this.zai) {
try {
this.zag = true;
ArrayList arrayList = this.zac;
ArrayList arrayList2 = new ArrayList(arrayList);
AtomicInteger atomicInteger = this.zaf;
int i2 = atomicInteger.get();
int size = arrayList2.size();
int i3 = 0;
while (i3 < size) {
Object obj = arrayList2.get(i3);
i3++;
GoogleApiClient.ConnectionCallbacks connectionCallbacks = (GoogleApiClient.ConnectionCallbacks) obj;
if (!this.zae || atomicInteger.get() != i2) {
break;
} else if (arrayList.contains(connectionCallbacks)) {
connectionCallbacks.onConnectionSuspended(i);
}
}
this.zaa.clear();
this.zag = false;
} catch (Throwable th) {
throw th;
}
}
}
@VisibleForTesting
public final void zae(ConnectionResult connectionResult) {
Handler handler = this.zah;
Preconditions.checkHandlerThread(handler, "onConnectionFailure must only be called on the Handler thread");
handler.removeMessages(1);
synchronized (this.zai) {
try {
ArrayList arrayList = this.zad;
ArrayList arrayList2 = new ArrayList(arrayList);
AtomicInteger atomicInteger = this.zaf;
int i = atomicInteger.get();
int size = arrayList2.size();
int i2 = 0;
while (i2 < size) {
Object obj = arrayList2.get(i2);
i2++;
GoogleApiClient.OnConnectionFailedListener onConnectionFailedListener = (GoogleApiClient.OnConnectionFailedListener) obj;
if (this.zae && atomicInteger.get() == i) {
if (arrayList.contains(onConnectionFailedListener)) {
onConnectionFailedListener.onConnectionFailed(connectionResult);
}
}
return;
}
} finally {
}
}
}
public final void zaf(GoogleApiClient.ConnectionCallbacks connectionCallbacks) {
Preconditions.checkNotNull(connectionCallbacks);
synchronized (this.zai) {
try {
ArrayList arrayList = this.zac;
if (arrayList.contains(connectionCallbacks)) {
String valueOf = String.valueOf(connectionCallbacks);
StringBuilder sb = new StringBuilder(valueOf.length() + 62);
sb.append("registerConnectionCallbacks(): listener ");
sb.append(valueOf);
sb.append(" is already registered");
Log.w("GmsClientEvents", sb.toString());
} else {
arrayList.add(connectionCallbacks);
}
} catch (Throwable th) {
throw th;
}
}
if (this.zab.isConnected()) {
Handler handler = this.zah;
handler.sendMessage(handler.obtainMessage(1, connectionCallbacks));
}
}
public final boolean zag(GoogleApiClient.ConnectionCallbacks connectionCallbacks) {
boolean contains;
Preconditions.checkNotNull(connectionCallbacks);
synchronized (this.zai) {
contains = this.zac.contains(connectionCallbacks);
}
return contains;
}
public final void zah(GoogleApiClient.ConnectionCallbacks connectionCallbacks) {
Preconditions.checkNotNull(connectionCallbacks);
synchronized (this.zai) {
try {
if (!this.zac.remove(connectionCallbacks)) {
String valueOf = String.valueOf(connectionCallbacks);
StringBuilder sb = new StringBuilder(valueOf.length() + 52);
sb.append("unregisterConnectionCallbacks(): listener ");
sb.append(valueOf);
sb.append(" not found");
Log.w("GmsClientEvents", sb.toString());
} else if (this.zag) {
this.zaa.add(connectionCallbacks);
}
} catch (Throwable th) {
throw th;
}
}
}
public final void zai(GoogleApiClient.OnConnectionFailedListener onConnectionFailedListener) {
Preconditions.checkNotNull(onConnectionFailedListener);
synchronized (this.zai) {
try {
ArrayList arrayList = this.zad;
if (arrayList.contains(onConnectionFailedListener)) {
String valueOf = String.valueOf(onConnectionFailedListener);
StringBuilder sb = new StringBuilder(valueOf.length() + 67);
sb.append("registerConnectionFailedListener(): listener ");
sb.append(valueOf);
sb.append(" is already registered");
Log.w("GmsClientEvents", sb.toString());
} else {
arrayList.add(onConnectionFailedListener);
}
} catch (Throwable th) {
throw th;
}
}
}
public final boolean zaj(GoogleApiClient.OnConnectionFailedListener onConnectionFailedListener) {
boolean contains;
Preconditions.checkNotNull(onConnectionFailedListener);
synchronized (this.zai) {
contains = this.zad.contains(onConnectionFailedListener);
}
return contains;
}
public final void zak(GoogleApiClient.OnConnectionFailedListener onConnectionFailedListener) {
Preconditions.checkNotNull(onConnectionFailedListener);
synchronized (this.zai) {
try {
if (!this.zad.remove(onConnectionFailedListener)) {
String valueOf = String.valueOf(onConnectionFailedListener);
StringBuilder sb = new StringBuilder(valueOf.length() + 57);
sb.append("unregisterConnectionFailedListener(): listener ");
sb.append(valueOf);
sb.append(" not found");
Log.w("GmsClientEvents", sb.toString());
}
} catch (Throwable th) {
throw th;
}
}
}
}