# Add project specific ProGuard rules here.

# --- Protobuf Rules ---
-keep class com.google.protobuf.** { *; }
-dontwarn com.google.protobuf.**
-keepattributes Signature, InnerClasses, EnclosingMethod, *Annotation*

# --- Generated Proto Classes ---
# Keep all generated protocol buffer classes and their members
-keep class com.andrerinas.openheadunit.aap.protocol.proto.** { *; }
-keep interface com.andrerinas.openheadunit.aap.protocol.proto.** { *; }
-keep enum com.andrerinas.openheadunit.aap.protocol.proto.** { *; }

# --- Reflection Targets ---
# Ensure these system classes are kept and their members are accessible via reflection
-keep class android.net.Network { *; }
-keep class android.net.wifi.WifiInfo { *; }

# --- AndroidX Navigation & Fragments ---
# Keep NavHostFragment and Navigation classes (referenced in XML)
-keep class androidx.navigation.** { *; }
-keep class androidx.fragment.app.FragmentContainerView { *; }

# Keep all fragments in the main package (referenced in nav_graph.xml)
-keep class com.andrerinas.openheadunit.main.** { *; }
-keep class com.andrerinas.openheadunit.main.settings.** { *; }

# --- App Logic ---
# Keep specific app classes if needed (e.g. accessed via JNI or reflection)
# -keep class com.andrerinas.openheadunit.decoder.** { *; }

# --- JNI ---
-keep class com.andrerinas.openheadunit.aap.AapSslNative { *; }
-keep class com.andrerinas.openheadunit.decoder.FfmpegHevcDecoder { *; }
-keep class com.andrerinas.openheadunit.decoder.FfmpegHevcDecoder$Companion { *; }

# --- Conscrypt Rules ---
-dontwarn org.conscrypt.**
-keep class org.conscrypt.Conscrypt { *; }
-keep class org.conscrypt.OpenSSLProvider { *; }

# --- Glide Rules ---
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep class * extends com.bumptech.glide.module.AppGlideModule { <init>(...); }
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** { **[] $VALUES; public *; }

# --- CarLink: rules for R8 in CarLink's release build ---
# HotspotManager calls dexmaker's TypeId.get(String) and TypeId.get(Class) through
# getDeclaredMethod (legacy tethering callback, Android 7-10).
-keepclassmembers class com.android.dx.TypeId {
    public static *** get(...);
}
# The Shizuku user service: Shizuku's server instantiates it by class name in its own process.
-keep class com.andrerinas.openheadunit.utils.SUExecutor$ShizukuImpl$PrivilegedService {
    <init>(...);
}
# BydCarServerTransport reads this Parcelable from a BYD provider's Bundle: the platform finds it
# by class name and reads CREATOR reflectively; the app never constructs it itself.
-keep class com.byd.spi.ipc.cursor.BinderCursor$BinderParcelable {
    public static final android.os.Parcelable$Creator CREATOR;
    public final android.os.IBinder binder;
}
