soul-browser/sources/java/com/google/api/client/util/escape/PercentEscaper.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

112 lines
4.3 KiB
Java

package com.google.api.client.util.escape;
import android.support.v4.media.a;
/* loaded from: classes3.dex */
public class PercentEscaper extends UnicodeEscaper {
public static final String SAFECHARS_URLENCODER = "-_.*";
public static final String SAFEPATHCHARS_URLENCODER = "-_.!~*'()@:$&,;=";
public static final String SAFEQUERYSTRINGCHARS_URLENCODER = "-_.!~*'()@:$,;/?:";
public static final String SAFEUSERINFOCHARS_URLENCODER = "-_.!~*'():$&,;=";
public static final String SAFE_PLUS_RESERVED_CHARS_URLENCODER = "-_.!~*'()@:$&,;=+/?#[]";
private final boolean plusForSpace;
private final boolean[] safeOctets;
private static final char[] URI_ESCAPED_SPACE = {'+'};
private static final char[] UPPER_HEX_DIGITS = "0123456789ABCDEF".toCharArray();
public PercentEscaper(String str) {
this(str, false);
}
private static boolean[] createSafeOctets(String str) {
char[] charArray = str.toCharArray();
int i = 122;
for (char c2 : charArray) {
i = Math.max((int) c2, i);
}
boolean[] zArr = new boolean[i + 1];
for (int i2 = 48; i2 <= 57; i2++) {
zArr[i2] = true;
}
for (int i3 = 65; i3 <= 90; i3++) {
zArr[i3] = true;
}
for (int i4 = 97; i4 <= 122; i4++) {
zArr[i4] = true;
}
for (char c3 : charArray) {
zArr[c3] = true;
}
return zArr;
}
@Override // com.google.api.client.util.escape.UnicodeEscaper, com.google.api.client.util.escape.Escaper
public String escape(String str) {
int length = str.length();
for (int i = 0; i < length; i++) {
char charAt = str.charAt(i);
boolean[] zArr = this.safeOctets;
if (charAt >= zArr.length || !zArr[charAt]) {
return escapeSlow(str, i);
}
}
return str;
}
@Override // com.google.api.client.util.escape.UnicodeEscaper
public int nextEscapeIndex(CharSequence charSequence, int i, int i2) {
while (i < i2) {
char charAt = charSequence.charAt(i);
boolean[] zArr = this.safeOctets;
if (charAt >= zArr.length || !zArr[charAt]) {
break;
}
i++;
}
return i;
}
@Deprecated
public PercentEscaper(String str, boolean z) {
if (!str.matches(".*[0-9A-Za-z].*")) {
if (z && str.contains(" ")) {
throw new IllegalArgumentException("plusForSpace cannot be specified when space is a 'safe' character");
}
if (!str.contains("%")) {
this.plusForSpace = z;
this.safeOctets = createSafeOctets(str);
return;
}
throw new IllegalArgumentException("The '%' character cannot be specified as 'safe'");
}
throw new IllegalArgumentException("Alphanumeric ASCII characters are always 'safe' and should not be escaped.");
}
@Override // com.google.api.client.util.escape.UnicodeEscaper
public char[] escape(int i) {
boolean[] zArr = this.safeOctets;
if (i < zArr.length && zArr[i]) {
return null;
}
if (i == 32 && this.plusForSpace) {
return URI_ESCAPED_SPACE;
}
if (i <= 127) {
char[] cArr = UPPER_HEX_DIGITS;
return new char[]{'%', cArr[i >>> 4], cArr[i & 15]};
}
if (i <= 2047) {
char[] cArr2 = UPPER_HEX_DIGITS;
return new char[]{'%', cArr2[(i >>> 10) | 12], cArr2[(i >>> 6) & 15], '%', cArr2[((i >>> 4) & 3) | 8], cArr2[i & 15]};
}
if (i <= 65535) {
char[] cArr3 = UPPER_HEX_DIGITS;
return new char[]{'%', 'E', cArr3[i >>> 12], '%', cArr3[((i >>> 10) & 3) | 8], cArr3[(i >>> 6) & 15], '%', cArr3[((i >>> 4) & 3) | 8], cArr3[i & 15]};
}
if (i <= 1114111) {
char[] cArr4 = UPPER_HEX_DIGITS;
return new char[]{'%', 'F', cArr4[(i >>> 18) & 7], '%', cArr4[((i >>> 16) & 3) | 8], cArr4[(i >>> 12) & 15], '%', cArr4[((i >>> 10) & 3) | 8], cArr4[(i >>> 6) & 15], '%', cArr4[((i >>> 4) & 3) | 8], cArr4[i & 15]};
}
throw new IllegalArgumentException(a.e(i, "Invalid unicode character value "));
}
}