soul-browser/sources/java/androidx/core/content/ContextCompat.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

264 lines
10 KiB
Java

package androidx.core.content;
import android.accounts.AccountManager;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.app.AlarmManager;
import android.app.AppOpsManager;
import android.app.DownloadManager;
import android.app.KeyguardManager;
import android.app.NotificationManager;
import android.app.SearchManager;
import android.app.UiModeManager;
import android.app.WallpaperManager;
import android.app.admin.DevicePolicyManager;
import android.app.job.JobScheduler;
import android.app.usage.UsageStatsManager;
import android.appwidget.AppWidgetManager;
import android.bluetooth.BluetoothManager;
import android.content.BroadcastReceiver;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.RestrictionsManager;
import android.content.pm.LauncherApps;
import android.content.res.ColorStateList;
import android.hardware.ConsumerIrManager;
import android.hardware.SensorManager;
import android.hardware.camera2.CameraManager;
import android.hardware.display.DisplayManager;
import android.hardware.input.InputManager;
import android.hardware.usb.UsbManager;
import android.location.LocationManager;
import android.media.AudioManager;
import android.media.MediaRouter;
import android.media.projection.MediaProjectionManager;
import android.media.session.MediaSessionManager;
import android.media.tv.TvInputManager;
import android.net.ConnectivityManager;
import android.net.nsd.NsdManager;
import android.net.wifi.WifiManager;
import android.net.wifi.p2p.WifiP2pManager;
import android.nfc.NfcManager;
import android.os.BatteryManager;
import android.os.Build;
import android.os.DropBoxManager;
import android.os.Handler;
import android.os.PowerManager;
import android.os.Process;
import android.os.UserManager;
import android.os.Vibrator;
import android.os.storage.StorageManager;
import android.print.PrintManager;
import android.support.v4.media.a;
import android.telecom.TelecomManager;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.CaptioningManager;
import android.view.inputmethod.InputMethodManager;
import android.view.textservice.TextServicesManager;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.os.ExecutorCompat;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
import java.util.concurrent.Executor;
@SuppressLint({"PrivateConstructorForUtilityClass"})
/* loaded from: classes.dex */
public class ContextCompat {
@RequiresApi
/* loaded from: classes.dex */
public static class Api21Impl {
}
@RequiresApi
/* loaded from: classes.dex */
public static class Api23Impl {
}
@RequiresApi
/* loaded from: classes.dex */
public static class Api24Impl {
}
@RequiresApi
/* loaded from: classes.dex */
public static class Api26Impl {
public static Intent a(Context context, BroadcastReceiver broadcastReceiver, IntentFilter intentFilter, Handler handler, int i) {
if ((i & 4) != 0) {
return context.registerReceiver(broadcastReceiver, intentFilter, ContextCompat.e(context), handler);
}
return context.registerReceiver(broadcastReceiver, intentFilter, null, handler, 0);
}
public static void b(Context context, Intent intent) {
context.startForegroundService(intent);
}
}
@RequiresApi
/* loaded from: classes.dex */
public static class Api28Impl {
public static Executor a(Context context) {
return context.getMainExecutor();
}
}
@RequiresApi
/* loaded from: classes.dex */
public static class Api30Impl {
public static String a(Context context) {
return context.getAttributionTag();
}
}
@RequiresApi
/* loaded from: classes.dex */
public static class Api33Impl {
public static Intent a(Context context, BroadcastReceiver broadcastReceiver, IntentFilter intentFilter, Handler handler, int i) {
return context.registerReceiver(broadcastReceiver, intentFilter, null, handler, i);
}
}
/* loaded from: classes.dex */
public static final class LegacyServiceMapHolder {
static {
HashMap hashMap = new HashMap();
hashMap.put(SubscriptionManager.class, "telephony_subscription_service");
hashMap.put(UsageStatsManager.class, "usagestats");
hashMap.put(AppWidgetManager.class, "appwidget");
hashMap.put(BatteryManager.class, "batterymanager");
hashMap.put(CameraManager.class, "camera");
hashMap.put(JobScheduler.class, "jobscheduler");
hashMap.put(LauncherApps.class, "launcherapps");
hashMap.put(MediaProjectionManager.class, "media_projection");
hashMap.put(MediaSessionManager.class, "media_session");
hashMap.put(RestrictionsManager.class, "restrictions");
hashMap.put(TelecomManager.class, "telecom");
hashMap.put(TvInputManager.class, "tv_input");
hashMap.put(AppOpsManager.class, "appops");
hashMap.put(CaptioningManager.class, "captioning");
hashMap.put(ConsumerIrManager.class, "consumer_ir");
hashMap.put(PrintManager.class, "print");
hashMap.put(BluetoothManager.class, "bluetooth");
hashMap.put(DisplayManager.class, "display");
hashMap.put(UserManager.class, "user");
hashMap.put(InputManager.class, "input");
hashMap.put(MediaRouter.class, "media_router");
hashMap.put(NsdManager.class, "servicediscovery");
hashMap.put(AccessibilityManager.class, "accessibility");
hashMap.put(AccountManager.class, "account");
hashMap.put(ActivityManager.class, "activity");
hashMap.put(AlarmManager.class, "alarm");
hashMap.put(AudioManager.class, "audio");
hashMap.put(ClipboardManager.class, "clipboard");
hashMap.put(ConnectivityManager.class, "connectivity");
hashMap.put(DevicePolicyManager.class, "device_policy");
hashMap.put(DownloadManager.class, "download");
hashMap.put(DropBoxManager.class, "dropbox");
hashMap.put(InputMethodManager.class, "input_method");
hashMap.put(KeyguardManager.class, "keyguard");
hashMap.put(LayoutInflater.class, "layout_inflater");
hashMap.put(LocationManager.class, "location");
hashMap.put(NfcManager.class, "nfc");
hashMap.put(NotificationManager.class, "notification");
hashMap.put(PowerManager.class, "power");
hashMap.put(SearchManager.class, "search");
hashMap.put(SensorManager.class, "sensor");
hashMap.put(StorageManager.class, "storage");
hashMap.put(TelephonyManager.class, "phone");
hashMap.put(TextServicesManager.class, "textservices");
hashMap.put(UiModeManager.class, "uimode");
hashMap.put(UsbManager.class, "usb");
hashMap.put(Vibrator.class, "vibrator");
hashMap.put(WallpaperManager.class, "wallpaper");
hashMap.put(WifiP2pManager.class, "wifip2p");
hashMap.put(WifiManager.class, "wifi");
hashMap.put(WindowManager.class, "window");
}
}
@Retention(RetentionPolicy.SOURCE)
@RestrictTo
/* loaded from: classes.dex */
public @interface RegisterReceiverFlags {
}
public static int a(Context context, String str) {
if (str != null) {
if (Build.VERSION.SDK_INT < 33 && TextUtils.equals("android.permission.POST_NOTIFICATIONS", str)) {
if (new NotificationManagerCompat(context).a()) {
return 0;
}
return -1;
}
return context.checkPermission(str, Process.myPid(), Process.myUid());
}
throw new NullPointerException("permission must be non-null");
}
public static String b(Context context) {
if (Build.VERSION.SDK_INT >= 30) {
return Api30Impl.a(context);
}
return null;
}
public static ColorStateList c(Context context, int i) {
return ResourcesCompat.b(i, context.getTheme(), context.getResources());
}
public static Executor d(Context context) {
if (Build.VERSION.SDK_INT >= 28) {
return Api28Impl.a(context);
}
return ExecutorCompat.a(new Handler(context.getMainLooper()));
}
public static String e(Context context) {
String str = context.getPackageName() + ".DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION";
if (PermissionChecker.a(context, str) == 0) {
return str;
}
throw new RuntimeException(a.l("Permission ", str, " is required by your application to receive broadcasts, please add it to your manifest"));
}
public static Intent f(Context context, BroadcastReceiver broadcastReceiver, IntentFilter intentFilter, Handler handler, int i) {
int i2 = i & 2;
if (i2 == 0 && (i & 4) == 0) {
throw new IllegalArgumentException("One of either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED is required");
}
if (i2 != 0 && (i & 4) != 0) {
throw new IllegalArgumentException("Cannot specify both RECEIVER_EXPORTED and RECEIVER_NOT_EXPORTED");
}
int i3 = Build.VERSION.SDK_INT;
if (i3 >= 33) {
return Api33Impl.a(context, broadcastReceiver, intentFilter, handler, i);
}
if (i3 >= 26) {
return Api26Impl.a(context, broadcastReceiver, intentFilter, handler, i);
}
if ((i & 4) != 0) {
return context.registerReceiver(broadcastReceiver, intentFilter, e(context), handler);
}
return context.registerReceiver(broadcastReceiver, intentFilter, null, handler);
}
public static void g(Context context, Intent intent) {
if (Build.VERSION.SDK_INT >= 26) {
Api26Impl.b(context, intent);
} else {
context.startService(intent);
}
}
}