
-keep public class com.biglybt.android.client.rpc.RPCException

-keepnames public class * implements java.lang.Exception 

############################

-keep public class * extends androidx.preference.PreferenceFragmentCompat

-keepnames class org.xbill.DNS.*

# Picasso
#-dontwarn com.squareup.okhttp.**
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-dontwarn com.squareup.okhttp.**
-dontwarn okio.**
-dontwarn javax.annotation.**
-dontwarn sun.net.spi.nameservice.**
-dontwarn org.conscrypt.**
-dontwarn com.biglybt.platform.**

-dontnote android.net.http.*
-dontnote org.apache.commons.codec.**
-dontnote org.apache.http.**

#### https://github.com/square/okhttp/blob/master/okhttp/src/main/resources/META-INF/proguard/okhttp3.pro

# JSR 305 annotations are for embedding nullability information.
-dontwarn javax.annotation.**

# A resource is loaded with a relative path so the package of this class must be preserved.
-keepnames class okhttp3.internal.publicsuffix.PublicSuffixDatabase

# 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 okhttp3.internal.platform.ConscryptPlatform

# NoSuchFieldError on Prefences.getStorage() on specific device (Skyworth Asia)
-keep class net.grandcentrix.tray.core.Preferences {
	*;
}
# keep them all and maybe Skyworth will work?
-keep class net.grandcentrix.** {
	*;
}

#############
# biglybt Core
#############

# This dnsjava class uses old Sun API
#-dontnote org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
#-dontwarn org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
# See http://stackoverflow.com/questions/5701126, happens in dnsjava
#-optimizations !code/allocation/variable

# This grep lists most reflection based class usage
# (\.get[a-z]*(Field|Method|Const)|loadClass|getClass\()

# This should take care of any plugin we add
# Keep all methods. Plugins can have IPC (via reflection) and there's random
# stuff core calls if present, like #load(PluginInterface) 
-keep,includedescriptorclasses class * implements com.biglybt.pif.Plugin {
    public *; 
}

# make sure all parameters and return types are also kept for plugininterface
-keep,includedescriptorclasses class com.biglybt.pif.local.** { *; }

-keepnames class * implements com.biglybt.pifimpl.local.ui.config.ParameterImpl

# DataSourceResolver stores class names in a file
# Although DataSourceResolver currently is only used in SWT, it's safer to just keep the names
# Alternatively, we could -assumenosideeffects class com.biglybt.core.util.DataSourceResolver { public static *; } 
-keepnames class * implements com.biglybt.core.util.DataSourceResolver.DataSourceImporter

# GlobalManagerImpl: GlobalManagerImpl.class.getClassLoader().loadClass("com.biglybt.core.history.impl.DownloadHistoryManagerImpl")
-keep class com.biglybt.core.history.impl.DownloadHistoryManagerImpl { *; }

-keep class com.biglybt.plugin.net.buddy.BuddyPluginUtils {
    peekChatAsync(...);
}

# We need the base classes in platform, but the platform/<patform_id>/* could be removed
-keep class com.biglybt.platform.* { *; }
# We use a uniquely named bouncycastle because some phone OSes included a 
# stripped down version.
-keep,includedescriptorclasses class org.gudy.bouncycastle.jce.provider.** { *; }

#core/src/com/biglybt/core/util/protocol/AzURLStreamHandlerFactory.java:forName(clsName)
-keep class com.biglybt.core.util.protocol.** { *; }

# Class.forName: CacheFileManagerFactory.DEFAULT_MANAGER
# can be overriden by system property "com.biglybt.core.diskmanager.cache.manager"
-keep class com.biglybt.core.diskmanager.cache.impl.CacheFileManagerImpl { *; }

#  SubscriptionManagerFactory: String impl = System.getProperty( "az.factory.subscriptionmanager.impl", "com.biglybt.core.subs.impl.SubscriptionManagerImpl" );
-keep class com.biglybt.core.subs.impl.SubscriptionManagerImpl { 
    public static *** preInitialise(...);
    public static *** getSingleton(...); 
}

-keep class com.biglybt.core.subs.SubscriptionManagerFactory {
    public static *** preInitialise(...);
    public static *** getSingleton(...); 
}

#core/src/com/biglybt/core/torrentdownloader/TorrentDownloaderFactory.java:forName(logged ? CLA_LOGGED : CLA_NORMAL).newInstance()
-keep class com.biglybt.core.torrentdownloader.impl.TorrentDownloader* { *; }

#core/src/com/biglybt/core/util/bloom/impl/BloomFilterImpl.java:forName( impl )
-keep class com.biglybt.core.util.bloom.** { *; }
-keep class com.biglybt.core.util.bloom.impl.** { *; }

# DownloadImpl.getTrackingName compares strings to parts of getClass().getName()
# Its call parameter is always a DownloadScrapeResult type
-keep class !com.biglybt.pifimpl.remote.**,* implements com.biglybt.pif.download.DownloadScrapeResult { *; }

-keep class * implements com.biglybt.plugin.extseed.ExternalSeedReaderFactory { *; }

-keep class com.biglybt.core.util.Constants {
  public static boolean DOWNLOAD_SOURCES_PRETEND_COMPLETE;
}

-keep class com.biglybt.core.util.StringInterner {
	public static boolean DISABLE_INTERNING;
}

-keep class com.biglybt.core.security.impl.SETrustingManager { *; }

# com.biglybt.pifimpl.local.ddb.DDBaseHelpers#xfer_migration
-keepnames class * implements com.biglybt.pif.ddb.DistributedDatabaseTransferType

-keepnames class com.biglybt.core.peermanager.unchoker.UnchokerFactory

#-whyareyoukeeping class com.biglybt.core.dht.transport.DHTTransport { public void unregisterTransferHandler(***); }

# Not needed for Android, but instantiated via classloader
#-keep class com.aelitis.azureus.core.devices.impl.DeviceManagerImpl { *; }

# mldht plugin uses ObjectOutputStream
-keepnames class * implements java.io.Serializable
-keepclassmembers class !com.biglybt.pifimpl.remote.**,* implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    !static !transient <fields>;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

#############

# Understand the @AssumeNoSideEffects support annotation.
-keep class com.biglybt.util.AssumeNoSideEffects

-assumenosideeffects class * {
    @com.biglybt.util.AssumeNoSideEffects <methods>;
}

-assumenosideeffects class * {
    @com.biglybt.util.AssumeNoSideEffects <fields>;
}

-assumenosideeffects class * {
    @com.biglybt.util.AssumeNoSideEffects <init>(...);
}
