# Copied most part from standard 'proguard-android.txt', but removed part, related with optimization. Library should not make a decision about turning optimization on or off.

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keepclassmembers class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator CREATOR;
}

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
# -dontwarn android.support.**

# Understand the @Keep support annotation.
-keep class androidx.annotation.Keep

-keep @androidx.annotation.Keep class * {*;}

-keepclasseswithmembers class * {
    @androidx.annotation.Keep <methods>;
}

-keepclasseswithmembers class * {
    @androidx.annotation.Keep <fields>;
}

-keepclasseswithmembers class * {
    @androidx.annotation.Keep <init>(...);
}
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/finik/work/android-sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

## Settings, recommended for libraries:
-keepparameternames
-keepattributes Exceptions, InnerClasses, Signature, Deprecated, SourceFile, LineNumberTable, *Annotation*, EnclosingMethod

# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames, includedescriptorclasses class * {
    native <methods>;
}

# NDK crash-handler JNI classes (BugseeDetectionCrashNdkNative,
# BugseeCrashpadMain) live in the bugsee-android-ndk extension module and
# carry their own keep rules there (ndk/consumer-rules.pro).

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

-keepclassmembers class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator CREATOR;
}

-keepclassmembers class * implements com.bugsee.library.shared.serialization.binary.BinarySerializable {
  public static final com.bugsee.library.shared.serialization.binary.BinarySerializable$Creator BINARY_CREATOR;
}

## End of settings, recommended for libraries


# Keep the public entities in place.
# Exclude internal packages and extension module packages — each extension
# ships its own consumer rules. When adding a new extension module, add its
# internal package here (e.g. !com.bugsee.library.newmodule.**).
#
# Note: classes under com.bugsee.library.interception.** are intentionally
# kept (not denylisted). The package contains both public coordinators
# called by BugseeInternal.launch / extension facades AND internal event
# hubs (NetworkEventHub, LogEventHub, InputEventHub). The hubs carry
# @RestrictTo(LIBRARY) for IDE/lint enforcement; extensions are expected
# to use BugseeInternal.add*EventListener instead of touching the hubs
# directly. Stripping the hubs would require splitting them into
# nested .internal subpackages — out of scope here.

-keepnames public class !com.bugsee.library.internal.**, !com.bugsee.library.communication.internal.**, !com.bugsee.library.feedback.**, !com.bugsee.library.remoting.**, !com.bugsee.library.okhttp.**, !com.bugsee.library.ktor2.**, !com.bugsee.library.ktor3.**, !com.bugsee.library.cronet.**, !com.bugsee.library.compose.**, com.bugsee.library.** {
    public <fields>;
    public <methods>;
}

-keepnames public interface !com.bugsee.library.internal.**, !com.bugsee.library.communication.internal.**, !com.bugsee.library.feedback.**, !com.bugsee.library.remoting.**, !com.bugsee.library.okhttp.**, !com.bugsee.library.ktor2.**, !com.bugsee.library.ktor3.**, !com.bugsee.library.cronet.**, !com.bugsee.library.compose.**, com.bugsee.library.** {
    public <methods>;
}

-keepnames public enum !com.bugsee.library.internal.**, !com.bugsee.library.communication.internal.**, !com.bugsee.library.feedback.**, !com.bugsee.library.remoting.**, !com.bugsee.library.okhttp.**, !com.bugsee.library.ktor2.**, !com.bugsee.library.ktor3.**, !com.bugsee.library.cronet.**, !com.bugsee.library.compose.**, com.bugsee.library.** {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep public class !com.bugsee.library.internal.**, !com.bugsee.library.communication.internal.**, !com.bugsee.library.feedback.**, !com.bugsee.library.remoting.**, !com.bugsee.library.okhttp.**, !com.bugsee.library.ktor2.**, !com.bugsee.library.ktor3.**, !com.bugsee.library.cronet.**, !com.bugsee.library.compose.**, com.bugsee.library.** {
    public <fields>;
    public <methods>;
}


## Settings for okhttp3copy
# Animal Sniffer compileOnly dependency to ensure APIs are compatible with older versions of Java.
-dontwarn org.codehaus.mojo.animal_sniffer.*

# OkHttp platform used only on JVM and when Conscrypt dependency is available.
-dontwarn com.bugsee.library.communication.internal.okhttp.internal.platform.ConscryptPlatform
-dontwarn org.conscrypt.Conscrypt$ProviderBuilder
-dontwarn org.conscrypt.Conscrypt
## End of settings for okhttp3copy.

## Settings for retrofit2copy
-dontwarn kotlinx.coroutines.CancellableContinuation
-dontwarn kotlinx.coroutines.CancellableContinuationImpl
-dontwarn kotlinx.coroutines.CoroutineDispatcher
-dontwarn kotlinx.coroutines.Dispatchers
## End of settings for retrofit2copy.

# Prevent re-obfuscation during app build — the core library is already
# obfuscated during its own self-build. Extension module packages are excluded
# here because each extension ships its own consumer-proguard-rules.pro.
-keep class !com.bugsee.library.obfuscation.TestClass,!com.bugsee.library.obfuscation.UnusedClass,!com.bugsee.library.internal.**,!com.bugsee.library.communication.internal.**,!com.bugsee.library.feedback.**,!com.bugsee.library.remoting.**,!com.bugsee.library.okhttp.**,!com.bugsee.library.ktor2.**,!com.bugsee.library.ktor3.**,!com.bugsee.library.cronet.**,!com.bugsee.library.compose.**,com.bugsee.library.** { *; }

# Keep methods, which can be called from JS
-keepclassmembers class * {
    @android.webkit.JavascriptInterface public <methods>;
}

# If client app compileSdkVersion <= 23 , compiler can't find some classes and methods, used
# in Bugsee library. It is ok, because we check API version in runtime, but proguard generates
# warnings like the following:
# Warning: com.bugsee.library.events.ActivityLifecycleHandler: can't find referenced method
# 'boolean isInMultiWindowMode()' in library class android.app.Activity
# That's why we need to add -dontwarn commands for new classes and classes, which have new
# methods in Android API ( > 23).
-dontwarn android.app.Activity
-dontwarn android.os.DeadSystemException
-dontwarn android.webkit.WebViewClient
-dontwarn android.webkit.WebResourceRequest
-dontwarn android.webkit.WebResourceError
-dontwarn android.os.LocaleList
-dontwarn java.util.Locale
-dontwarn java.util.Locale$Category
-dontwarn android.view.View
-dontwarn android.view.View$OnScrollChangeListener
-dontwarn android.view.DisplayListCanvas
-dontwarn android.view.RenderNode
-dontwarn android.view.ThreadedRenderer
-dontwarn android.content.Context
-dontwarn com.bugsee.library.capture.providers.screen.ScreenCaptureRequestPermissionsActivity
-dontwarn android.app.NotificationChannel
-dontwarn android.app.NotificationManager
-dontwarn android.app.Notification$Builder
# Keep BugseeOperationDispatcher public static methods called by bytecode instrumentation
-keep class com.bugsee.library.adapters.BugseeOperationDispatcher {
    public static void on*(...);
}

# Keep BugseeAppStartupDispatcher public static methods called by bytecode instrumentation.
# The bugsee-android-gradle-plugin's app-startup tracing rewrites Application /
# ContentProvider / Initializer / etc. init methods (and `@BugseeTrace`-annotated
# methods at FULL tier) to emit `INVOKESTATIC` calls against the fourteen entry
# points on this class. Six generic + call/loop ones —
# `onMethodStart`, `onMethodEnd`, `onCallStart`, `onCallEnd`, `onLoopStart`,
# `onLoopEnd` — and eight kind-distinguished ones (issue 2) —
# `onApplicationStart/End`, `onProviderStart/End`, `onActivityStart/End`,
# `onAnnotatedStart/End`. They MUST keep their exact (Ljava/lang/String;)V
# signatures and method names; R8 renaming any of them would silently break the
# runtime contract (the plugin's emitted bytecode references them by name). The
# `on*` wildcard below covers all current and future on-prefixed entry points
# added on either side of the contract. The umbrella `-keep class
# com.bugsee.library.**` rule at the bottom of this file functionally covers
# this class today, but adapter classes targeted by bytecode instrumentation
# should be explicitly pinned by name for defense-in-depth — symmetrical with
# the OperationDispatcher rule above.
-keep class com.bugsee.library.adapters.BugseeAppStartupDispatcher {
    public static void on*(...);
}

# Keep BugseeInitProvider.initializeExtensions — bytecode-instrumented by the
# bugsee-android-gradle-plugin's `optimizeExtensionsLoading` feature. The
# plugin strips every extension <provider> from the merged manifest and
# rewrites this method to INVOKESTATIC each `Bugsee<Name>.register<Name>Extension()`
# instead, so the method must survive R8 even when its source-level body
# looks like a no-op. The umbrella `-keep class … com.bugsee.library.**`
# rule at the top of this file functionally covers this today, but pin
# explicitly for defense-in-depth — symmetrical with the OperationDispatcher
# and AppStartupDispatcher rules above. The @Keep annotation on the method
# also covers it via android-proguard-rules.pro's @Keep handling; this rule
# is the third independent layer.
-keepclassmembers class com.bugsee.library.BugseeInitProvider {
    void initializeExtensions();
}

# Keep the @BugseeTrace marker annotation. The plugin reads it at COMPILE time
# (descriptor-string match against bytecode, not classpath-resolved), so this
# annotation does not need to survive R8 for the instrumentation to work — but
# defense-in-depth: a consumer that introspects annotations via reflection
# (rare but possible) or a future plugin revision that defers the descriptor
# match to runtime would both fail silently if the type were stripped. The
# annotation is CLASS-retention so it's already stripped from runtime by the
# JVM, but the class declaration itself must survive R8.
-keep class com.bugsee.library.contracts.performance.BugseeTrace

# Keep BugseeFileInputStream/BugseeFileOutputStream — type-remapped by bytecode instrumentation
-keep class com.bugsee.library.adapters.BugseeFileInputStream { <init>(...); }
-keep class com.bugsee.library.adapters.BugseeFileOutputStream { <init>(...); }

## End of custom Bugsee library settings

## Settings for okhttp, okhttp3
-keep class com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-keep class okhttp3.** {*; }
-dontwarn okhttp3.**
## End of settings for okhttp, okhttp3


## Settings for retrofit
-dontwarn retrofit2.**
-keep class retrofit2.** { *; }
#-keepattributes Signature
#-keepattributes Exceptions

#-keepattributes *Annotation*
## End of settings for retrofit.

-dontwarn okio.**

# Ktor
-dontwarn io.ktor.**

# Jetpack Compose (compileOnly) suppress warnings for missing classes
-dontwarn androidx.compose.**
-dontwarn androidx.activity.compose.**
-dontwarn androidx.lifecycle.compose.**
-dontwarn androidx.navigation.compose.**
-dontwarn androidx.compose.ui.tooling.**
-dontwarn androidx.compose.material.**
-dontwarn androidx.compose.material3.**
-dontwarn androidx.compose.foundation.**
-dontwarn androidx.activity.compose.**

# Picasso
-dontwarn com.squareup.picasso.**

# AndroidX
-dontwarn com.google.android.material.**