soul-browser/sources/java/com/google/api/client/http/OpenCensusUtils.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

165 lines
5.6 KiB
Java

package com.google.api.client.http;
import com.google.api.client.util.Beta;
import com.google.api.client.util.Preconditions;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableList;
import io.opencensus.contrib.http.util.HttpPropagationUtil;
import io.opencensus.trace.BlankSpan;
import io.opencensus.trace.EndSpanOptions;
import io.opencensus.trace.MessageEvent;
import io.opencensus.trace.Span;
import io.opencensus.trace.Status;
import io.opencensus.trace.Tracer;
import io.opencensus.trace.Tracing;
import io.opencensus.trace.propagation.TextFormat;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
@Beta
/* loaded from: classes3.dex */
public class OpenCensusUtils {
private static final AtomicLong idGenerator;
private static volatile boolean isRecordEvent;
@VisibleForTesting
@Nullable
static volatile TextFormat propagationTextFormat;
@VisibleForTesting
@Nullable
static volatile TextFormat.Setter propagationTextFormatSetter;
private static final Tracer tracer;
private static final Logger logger = Logger.getLogger(OpenCensusUtils.class.getName());
public static final String SPAN_NAME_HTTP_REQUEST_EXECUTE = "Sent." + HttpRequest.class.getName() + ".execute";
static {
Tracing.f21118a.getClass();
tracer = Tracer.f21116a;
idGenerator = new AtomicLong();
isRecordEvent = true;
propagationTextFormat = null;
propagationTextFormatSetter = null;
try {
propagationTextFormat = HttpPropagationUtil.a();
propagationTextFormatSetter = new TextFormat.Setter<HttpHeaders>() { // from class: com.google.api.client.http.OpenCensusUtils.1
@Override // io.opencensus.trace.propagation.TextFormat.Setter
public void put(HttpHeaders httpHeaders, String str, String str2) {
httpHeaders.set(str, (Object) str2);
}
};
} catch (Exception e) {
logger.log(Level.WARNING, "Cannot initialize default OpenCensus HTTP propagation text format.", (Throwable) e);
}
try {
Tracing.f21118a.a().a().a(ImmutableList.w(SPAN_NAME_HTTP_REQUEST_EXECUTE));
} catch (Exception e2) {
logger.log(Level.WARNING, "Cannot register default OpenCensus span names for collection.", (Throwable) e2);
}
}
private OpenCensusUtils() {
}
public static EndSpanOptions getEndSpanOptions(@Nullable Integer num) {
EndSpanOptions.Builder a2 = EndSpanOptions.a();
if (num == null) {
a2.b(Status.e);
} else if (!HttpStatusCodes.isSuccess(num.intValue())) {
int intValue = num.intValue();
if (intValue != 400) {
if (intValue != 401) {
if (intValue != 403) {
if (intValue != 404) {
if (intValue != 412) {
if (intValue != 500) {
a2.b(Status.e);
} else {
a2.b(Status.k);
}
} else {
a2.b(Status.j);
}
} else {
a2.b(Status.g);
}
} else {
a2.b(Status.h);
}
} else {
a2.b(Status.i);
}
} else {
a2.b(Status.f);
}
} else {
a2.b(Status.d);
}
return a2.a();
}
public static Tracer getTracer() {
return tracer;
}
public static boolean isRecordEvent() {
return isRecordEvent;
}
public static void propagateTracingContext(Span span, HttpHeaders httpHeaders) {
boolean z;
boolean z2 = false;
if (span != null) {
z = true;
} else {
z = false;
}
Preconditions.checkArgument(z, "span should not be null.");
if (httpHeaders != null) {
z2 = true;
}
Preconditions.checkArgument(z2, "headers should not be null.");
if (propagationTextFormat != null && propagationTextFormatSetter != null && !span.equals(BlankSpan.f21099c)) {
propagationTextFormat.a(span.f21105a, httpHeaders, propagationTextFormatSetter);
}
}
@VisibleForTesting
public static void recordMessageEvent(Span span, long j, MessageEvent.Type type) {
boolean z;
if (span != null) {
z = true;
} else {
z = false;
}
Preconditions.checkArgument(z, "span should not be null.");
if (j < 0) {
j = 0;
}
MessageEvent.Builder a2 = MessageEvent.a(type, idGenerator.getAndIncrement());
a2.b(j);
span.a(a2.a());
}
public static void recordReceivedMessageEvent(Span span, long j) {
recordMessageEvent(span, j, MessageEvent.Type.f);
}
public static void recordSentMessageEvent(Span span, long j) {
recordMessageEvent(span, j, MessageEvent.Type.f21103c);
}
public static void setIsRecordEvent(boolean z) {
isRecordEvent = z;
}
public static void setPropagationTextFormat(@Nullable TextFormat textFormat) {
propagationTextFormat = textFormat;
}
public static void setPropagationTextFormatSetter(@Nullable TextFormat.Setter setter) {
propagationTextFormatSetter = setter;
}
}