soul-browser/sources/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.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

357 lines
14 KiB
Java

package com.google.api.client.googleapis.services;
import android.support.v4.media.a;
import com.google.api.client.googleapis.GoogleUtils;
import com.google.api.client.googleapis.MethodOverride;
import com.google.api.client.googleapis.batch.BatchCallback;
import com.google.api.client.googleapis.batch.BatchRequest;
import com.google.api.client.googleapis.media.MediaHttpDownloader;
import com.google.api.client.googleapis.media.MediaHttpUploader;
import com.google.api.client.http.AbstractInputStreamContent;
import com.google.api.client.http.EmptyContent;
import com.google.api.client.http.GZipEncoding;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpContent;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpMethods;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpResponseException;
import com.google.api.client.http.HttpResponseInterceptor;
import com.google.api.client.http.UriTemplate;
import com.google.api.client.util.GenericData;
import com.google.api.client.util.Preconditions;
import com.google.common.base.Joiner;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/* loaded from: classes3.dex */
public abstract class AbstractGoogleClientRequest<T> extends GenericData {
private static final String API_VERSION_HEADER = "X-Goog-Api-Client";
public static final String USER_AGENT_SUFFIX = "Google-API-Java-Client";
private final AbstractGoogleClient abstractGoogleClient;
private boolean disableGZipContent;
private MediaHttpDownloader downloader;
private final HttpContent httpContent;
private HttpHeaders lastResponseHeaders;
private String lastStatusMessage;
private final String requestMethod;
private Class<T> responseClass;
private boolean returnRawInputStream;
private MediaHttpUploader uploader;
private final String uriTemplate;
private HttpHeaders requestHeaders = new HttpHeaders();
private int lastStatusCode = -1;
/* loaded from: classes3.dex */
public static class ApiClientVersion {
static final String DEFAULT_VERSION = new ApiClientVersion().toString();
private final String versionString;
public ApiClientVersion() {
this(getJavaVersion(), System.getProperty("os.name"), System.getProperty("os.version"), GoogleUtils.VERSION);
}
private static String formatName(String str) {
return str.toLowerCase().replaceAll("[^\\w\\d\\-]", "-");
}
private static String formatSemver(String str) {
return formatSemver(str, str);
}
private static String getJavaVersion() {
String property = System.getProperty("java.version");
if (property == null) {
return null;
}
String formatSemver = formatSemver(property, null);
if (formatSemver != null) {
return formatSemver;
}
Matcher matcher = Pattern.compile("^(\\d+)[^\\d]?").matcher(property);
if (!matcher.find()) {
return null;
}
return matcher.group(1) + ".0.0";
}
public String toString() {
String property = System.getProperty("org.graalvm.nativeimage.imagecode");
if (property != null && property.equals("runtime")) {
String[] split2 = this.versionString.split(" ");
if (split2.length > 0 && split2[0].startsWith("gl-java")) {
split2[0] = a.p(new StringBuilder(), split2[0], "-graalvm");
return new Joiner(" ").b(Arrays.asList(split2));
}
}
return this.versionString;
}
private static String formatSemver(String str, String str2) {
if (str == null) {
return null;
}
Matcher matcher = Pattern.compile("(\\d+\\.\\d+\\.\\d+).*").matcher(str);
return matcher.find() ? matcher.group(1) : str2;
}
public ApiClientVersion(String str, String str2, String str3, String str4) {
StringBuilder sb = new StringBuilder("gl-java/");
sb.append(formatSemver(str));
sb.append(" gdcl/");
sb.append(formatSemver(str4));
if (str2 != null && str3 != null) {
sb.append(" ");
sb.append(formatName(str2));
sb.append("/");
sb.append(formatSemver(str3));
}
this.versionString = sb.toString();
}
}
public AbstractGoogleClientRequest(AbstractGoogleClient abstractGoogleClient, String str, String str2, HttpContent httpContent, Class<T> cls) {
this.responseClass = (Class) Preconditions.checkNotNull(cls);
this.abstractGoogleClient = (AbstractGoogleClient) Preconditions.checkNotNull(abstractGoogleClient);
this.requestMethod = (String) Preconditions.checkNotNull(str);
this.uriTemplate = (String) Preconditions.checkNotNull(str2);
this.httpContent = httpContent;
String applicationName = abstractGoogleClient.getApplicationName();
if (applicationName != null) {
HttpHeaders httpHeaders = this.requestHeaders;
StringBuilder v = a.v(applicationName, " Google-API-Java-Client/");
v.append(GoogleUtils.VERSION);
httpHeaders.setUserAgent(v.toString());
} else {
this.requestHeaders.setUserAgent("Google-API-Java-Client/" + GoogleUtils.VERSION);
}
this.requestHeaders.set(API_VERSION_HEADER, (Object) ApiClientVersion.DEFAULT_VERSION);
}
public HttpRequest buildHttpRequest() {
return buildHttpRequest(false);
}
public GenericUrl buildHttpRequestUrl() {
return new GenericUrl(UriTemplate.expand(this.abstractGoogleClient.getBaseUrl(), this.uriTemplate, this, true));
}
public HttpRequest buildHttpRequestUsingHead() {
return buildHttpRequest(true);
}
public final void checkRequiredParameter(Object obj, String str) {
boolean z;
if (!this.abstractGoogleClient.getSuppressRequiredParameterChecks() && obj == null) {
z = false;
} else {
z = true;
}
Preconditions.checkArgument(z, "Required parameter %s must be specified", str);
}
public T execute() {
return (T) executeUnparsed().parseAs((Class) this.responseClass);
}
public void executeAndDownloadTo(OutputStream outputStream) {
executeUnparsed().download(outputStream);
}
public InputStream executeAsInputStream() {
return executeUnparsed().getContent();
}
public HttpResponse executeMedia() {
set("alt", (Object) "media");
return executeUnparsed();
}
public void executeMediaAndDownloadTo(OutputStream outputStream) {
MediaHttpDownloader mediaHttpDownloader = this.downloader;
if (mediaHttpDownloader == null) {
executeMedia().download(outputStream);
} else {
mediaHttpDownloader.download(buildHttpRequestUrl(), this.requestHeaders, outputStream);
}
}
public InputStream executeMediaAsInputStream() {
return executeMedia().getContent();
}
public HttpResponse executeUnparsed() {
return executeUnparsed(false);
}
public HttpResponse executeUsingHead() {
boolean z;
if (this.uploader == null) {
z = true;
} else {
z = false;
}
Preconditions.checkArgument(z);
HttpResponse executeUnparsed = executeUnparsed(true);
executeUnparsed.ignore();
return executeUnparsed;
}
public AbstractGoogleClient getAbstractGoogleClient() {
return this.abstractGoogleClient;
}
public final boolean getDisableGZipContent() {
return this.disableGZipContent;
}
public final HttpContent getHttpContent() {
return this.httpContent;
}
public final HttpHeaders getLastResponseHeaders() {
return this.lastResponseHeaders;
}
public final int getLastStatusCode() {
return this.lastStatusCode;
}
public final String getLastStatusMessage() {
return this.lastStatusMessage;
}
public final MediaHttpDownloader getMediaHttpDownloader() {
return this.downloader;
}
public final MediaHttpUploader getMediaHttpUploader() {
return this.uploader;
}
public final HttpHeaders getRequestHeaders() {
return this.requestHeaders;
}
public final String getRequestMethod() {
return this.requestMethod;
}
public final Class<T> getResponseClass() {
return this.responseClass;
}
public final boolean getReturnRawInputSteam() {
return this.returnRawInputStream;
}
public final String getUriTemplate() {
return this.uriTemplate;
}
public final void initializeMediaDownload() {
HttpRequestFactory requestFactory = this.abstractGoogleClient.getRequestFactory();
this.downloader = new MediaHttpDownloader(requestFactory.getTransport(), requestFactory.getInitializer());
}
public final void initializeMediaUpload(AbstractInputStreamContent abstractInputStreamContent) {
HttpRequestFactory requestFactory = this.abstractGoogleClient.getRequestFactory();
MediaHttpUploader mediaHttpUploader = new MediaHttpUploader(abstractInputStreamContent, requestFactory.getTransport(), requestFactory.getInitializer());
this.uploader = mediaHttpUploader;
mediaHttpUploader.setInitiationRequestMethod(this.requestMethod);
HttpContent httpContent = this.httpContent;
if (httpContent != null) {
this.uploader.setMetadata(httpContent);
}
}
public IOException newExceptionOnError(HttpResponse httpResponse) {
return new HttpResponseException(httpResponse);
}
public final <E> void queue(BatchRequest batchRequest, Class<E> cls, BatchCallback<T, E> batchCallback) {
boolean z;
if (this.uploader == null) {
z = true;
} else {
z = false;
}
Preconditions.checkArgument(z, "Batching media requests is not supported");
batchRequest.queue(buildHttpRequest(), getResponseClass(), cls, batchCallback);
}
public AbstractGoogleClientRequest<T> setDisableGZipContent(boolean z) {
this.disableGZipContent = z;
return this;
}
public AbstractGoogleClientRequest<T> setRequestHeaders(HttpHeaders httpHeaders) {
this.requestHeaders = httpHeaders;
return this;
}
public AbstractGoogleClientRequest<T> setReturnRawInputStream(boolean z) {
this.returnRawInputStream = z;
return this;
}
private HttpRequest buildHttpRequest(boolean z) {
Preconditions.checkArgument(this.uploader == null);
Preconditions.checkArgument(!z || this.requestMethod.equals(HttpMethods.GET));
final HttpRequest buildRequest = getAbstractGoogleClient().getRequestFactory().buildRequest(z ? HttpMethods.HEAD : this.requestMethod, buildHttpRequestUrl(), this.httpContent);
new MethodOverride().intercept(buildRequest);
buildRequest.setParser(getAbstractGoogleClient().getObjectParser());
if (this.httpContent == null && (this.requestMethod.equals(HttpMethods.POST) || this.requestMethod.equals(HttpMethods.PUT) || this.requestMethod.equals(HttpMethods.PATCH))) {
buildRequest.setContent(new EmptyContent());
}
buildRequest.getHeaders().putAll(this.requestHeaders);
if (!this.disableGZipContent) {
buildRequest.setEncoding(new GZipEncoding());
}
buildRequest.setResponseReturnRawInputStream(this.returnRawInputStream);
final HttpResponseInterceptor responseInterceptor = buildRequest.getResponseInterceptor();
buildRequest.setResponseInterceptor(new HttpResponseInterceptor() { // from class: com.google.api.client.googleapis.services.AbstractGoogleClientRequest.1
@Override // com.google.api.client.http.HttpResponseInterceptor
public void interceptResponse(HttpResponse httpResponse) {
HttpResponseInterceptor httpResponseInterceptor = responseInterceptor;
if (httpResponseInterceptor != null) {
httpResponseInterceptor.interceptResponse(httpResponse);
}
if (!httpResponse.isSuccessStatusCode() && buildRequest.getThrowExceptionOnExecuteError()) {
throw AbstractGoogleClientRequest.this.newExceptionOnError(httpResponse);
}
}
});
return buildRequest;
}
private HttpResponse executeUnparsed(boolean z) {
HttpResponse upload;
if (this.uploader == null) {
upload = buildHttpRequest(z).execute();
} else {
GenericUrl buildHttpRequestUrl = buildHttpRequestUrl();
boolean throwExceptionOnExecuteError = getAbstractGoogleClient().getRequestFactory().buildRequest(this.requestMethod, buildHttpRequestUrl, this.httpContent).getThrowExceptionOnExecuteError();
upload = this.uploader.setInitiationHeaders(this.requestHeaders).setDisableGZipContent(this.disableGZipContent).upload(buildHttpRequestUrl);
upload.getRequest().setParser(getAbstractGoogleClient().getObjectParser());
if (throwExceptionOnExecuteError && !upload.isSuccessStatusCode()) {
throw newExceptionOnError(upload);
}
}
this.lastResponseHeaders = upload.getHeaders();
this.lastStatusCode = upload.getStatusCode();
this.lastStatusMessage = upload.getStatusMessage();
return upload;
}
@Override // com.google.api.client.util.GenericData
public AbstractGoogleClientRequest<T> set(String str, Object obj) {
return (AbstractGoogleClientRequest) super.set(str, obj);
}
}