soul-browser/sources/java/com/google/ads/mediation/AbstractAdViewAdapter.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

188 lines
7.6 KiB
Java

package com.google.ads.mediation;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.ads.mediation.admob.AdMobAdapter;
import com.google.android.gms.ads.AdLoader;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.internal.client.zzbb;
import com.google.android.gms.ads.internal.client.zzed;
import com.google.android.gms.ads.internal.util.client.zzf;
import com.google.android.gms.ads.interstitial.InterstitialAd;
import com.google.android.gms.ads.mediation.MediationAdRequest;
import com.google.android.gms.ads.mediation.MediationBannerAdapter;
import com.google.android.gms.ads.mediation.MediationBannerListener;
import com.google.android.gms.ads.mediation.MediationInterstitialAdapter;
import com.google.android.gms.ads.mediation.MediationInterstitialListener;
import com.google.android.gms.ads.mediation.MediationNativeAdapter;
import com.google.android.gms.ads.mediation.MediationNativeListener;
import com.google.android.gms.ads.mediation.NativeMediationAdRequest;
import com.google.android.gms.ads.mediation.OnImmersiveModeUpdatedListener;
import java.util.Iterator;
import java.util.Set;
/* loaded from: classes.dex */
public abstract class AbstractAdViewAdapter implements MediationBannerAdapter, MediationInterstitialAdapter, MediationNativeAdapter, OnImmersiveModeUpdatedListener, com.google.android.gms.ads.mediation.zza {
@NonNull
public static final String AD_UNIT_ID_PARAMETER = "pubid";
private AdLoader adLoader;
@NonNull
protected AdView mAdView;
@NonNull
protected InterstitialAd mInterstitialAd;
public AdRequest buildAdRequest(Context context, MediationAdRequest mediationAdRequest, Bundle bundle, Bundle bundle2) {
AdRequest.Builder builder = new AdRequest.Builder();
Set<String> keywords = mediationAdRequest.getKeywords();
if (keywords != null) {
Iterator<String> it = keywords.iterator();
while (it.hasNext()) {
builder.addKeyword(it.next());
}
}
if (mediationAdRequest.isTesting()) {
zzbb.zza();
builder.zzb(zzf.zzD(context));
}
if (mediationAdRequest.taggedForChildDirectedTreatment() != -1) {
boolean z = true;
if (mediationAdRequest.taggedForChildDirectedTreatment() != 1) {
z = false;
}
builder.zzc(z);
}
builder.zzd(mediationAdRequest.isDesignedForFamilies());
builder.addNetworkExtrasBundle(AdMobAdapter.class, buildExtrasBundle(bundle, bundle2));
return builder.build();
}
public abstract Bundle buildExtrasBundle(Bundle bundle, Bundle bundle2);
@NonNull
public String getAdUnitId(@NonNull Bundle bundle) {
return bundle.getString(AD_UNIT_ID_PARAMETER);
}
@Override // com.google.android.gms.ads.mediation.MediationBannerAdapter
@NonNull
public View getBannerView() {
return this.mAdView;
}
@VisibleForTesting
public InterstitialAd getInterstitialAd() {
return this.mInterstitialAd;
}
@Override // com.google.android.gms.ads.mediation.zza
@Nullable
public zzed getVideoController() {
AdView adView = this.mAdView;
if (adView != null) {
return adView.zza().zzb();
}
return null;
}
@VisibleForTesting
public AdLoader.Builder newAdLoader(Context context, String str) {
return new AdLoader.Builder(context, str);
}
@Override // com.google.android.gms.ads.mediation.MediationAdapter
public void onDestroy() {
AdView adView = this.mAdView;
if (adView != null) {
adView.destroy();
this.mAdView = null;
}
if (this.mInterstitialAd != null) {
this.mInterstitialAd = null;
}
if (this.adLoader != null) {
this.adLoader = null;
}
}
@Override // com.google.android.gms.ads.mediation.OnImmersiveModeUpdatedListener
public void onImmersiveModeUpdated(boolean z) {
InterstitialAd interstitialAd = this.mInterstitialAd;
if (interstitialAd != null) {
interstitialAd.setImmersiveMode(z);
}
}
@Override // com.google.android.gms.ads.mediation.MediationAdapter
public void onPause() {
AdView adView = this.mAdView;
if (adView != null) {
adView.pause();
}
}
@Override // com.google.android.gms.ads.mediation.MediationAdapter
public void onResume() {
AdView adView = this.mAdView;
if (adView != null) {
adView.resume();
}
}
@Override // com.google.android.gms.ads.mediation.MediationBannerAdapter
public void requestBannerAd(@NonNull Context context, @NonNull MediationBannerListener mediationBannerListener, @NonNull Bundle bundle, @NonNull AdSize adSize, @NonNull MediationAdRequest mediationAdRequest, @NonNull Bundle bundle2) {
AdView adView = new AdView(context);
this.mAdView = adView;
adView.setAdSize(new AdSize(adSize.getWidth(), adSize.getHeight()));
this.mAdView.setAdUnitId(getAdUnitId(bundle));
this.mAdView.setAdListener(new zzb(this, mediationBannerListener));
this.mAdView.loadAd(buildAdRequest(context, mediationAdRequest, bundle2, bundle));
}
@Override // com.google.android.gms.ads.mediation.MediationInterstitialAdapter
public void requestInterstitialAd(@NonNull Context context, @NonNull MediationInterstitialListener mediationInterstitialListener, @NonNull Bundle bundle, @NonNull MediationAdRequest mediationAdRequest, @NonNull Bundle bundle2) {
InterstitialAd.load(context, getAdUnitId(bundle), buildAdRequest(context, mediationAdRequest, bundle2, bundle), new zzc(this, mediationInterstitialListener));
}
@Override // com.google.android.gms.ads.mediation.MediationNativeAdapter
public void requestNativeAd(@NonNull Context context, @NonNull MediationNativeListener mediationNativeListener, @NonNull Bundle bundle, @NonNull NativeMediationAdRequest nativeMediationAdRequest, @NonNull Bundle bundle2) {
zze zzeVar;
zze zzeVar2 = new zze(this, mediationNativeListener);
AdLoader.Builder newAdLoader = newAdLoader(context, bundle.getString(AD_UNIT_ID_PARAMETER));
newAdLoader.withAdListener(zzeVar2);
newAdLoader.zzc(nativeMediationAdRequest.getNativeAdOptions());
newAdLoader.withNativeAdOptions(nativeMediationAdRequest.getNativeAdRequestOptions());
if (nativeMediationAdRequest.isUnifiedNativeAdRequested()) {
newAdLoader.zza(zzeVar2);
}
if (nativeMediationAdRequest.zza()) {
for (String str : nativeMediationAdRequest.zzb().keySet()) {
if (true != ((Boolean) nativeMediationAdRequest.zzb().get(str)).booleanValue()) {
zzeVar = null;
} else {
zzeVar = zzeVar2;
}
newAdLoader.zzb(str, zzeVar2, zzeVar);
}
}
AdLoader build = newAdLoader.build();
this.adLoader = build;
build.loadAd(buildAdRequest(context, nativeMediationAdRequest, bundle2, bundle));
}
@Override // com.google.android.gms.ads.mediation.MediationInterstitialAdapter
public void showInterstitial() {
InterstitialAd interstitialAd = this.mInterstitialAd;
if (interstitialAd != null) {
interstitialAd.show(null);
}
}
}