Proguard Rules, Notification, and Analytics Configurations
The documentation provides configuration and code snippets for integrating VPN capabilities into Android apps.
Proguard Rules
ProGuard is a tool that obfuscates, optimizes, and shrinks your code by removing unused code and renaming classes, fields, and methods with semantically obscure names.
Usage
Copy the provided ProGuard rules into your project's proguard-rules.pro file.
Make sure to include this file in your build configuration:
Proguard rules are included in the SDK, but you can add your own custom rules if needed. Here's a breakdown of what each rule does:
-keep class * extends unified.vpn.sdk.ReportUrlProvider {
public <init>(...);
}
-keep class * extends unified.vpn.sdk.BaseInfoCollector {
public <init>(...);
}
-keep class * extends unified.vpn.sdk.TrackerTransportFactory {
public <init>(...);
}
-keep class * extends unified.vpn.sdk.CredentialsSource {
public <init>(...);
}
-keep class * extends unified.vpn.sdk.SdkTrackerDelegate {
public <init>(...);
}
-keep enum unified.vpn.sdk.UnifiedSDKConfig$CallbackMode {
*;
}
-keep class * extends unified.vpn.sdk.IStartConfigPatcher {
public <init>(...);
}
-keep class * extends unified.vpn.sdk.ConfigPatcherFactory {
public <init>(...);
}
-keep class * extends unified.vpn.sdk.IMiddleConfigPatcher {
public <init>(...);
}
#DNSJava
-keep class * implements com.google.gson.TypeAdapterFactory
-keep class * implements com.google.gson.JsonSerializer
-keep class * implements com.google.gson.JsonDeserializer
-keepclassmembers class * implements javax.net.ssl.SSLSocketFactory {
final javax.net.ssl.SSLSocketFactory delegate;
}
# https://stackoverflow.com/questions/56142150/fatal-exception-java-lang-nullpointerexception-in-release-build
-keepclassmembers,allowobfuscation class * {
@com.google.gson.annotations.SerializedName <fields>;
}
-dontwarn org.bouncycastle.jsse.BCSSLParameters
-dontwarn org.bouncycastle.jsse.BCSSLSocket
-dontwarn org.bouncycastle.jsse.provider.BouncyCastleJsseProvider
-dontwarn org.conscrypt.Conscrypt$Version
-dontwarn org.conscrypt.Conscrypt
-dontwarn org.conscrypt.ConscryptHostnameVerifier
-dontwarn org.openjsse.javax.net.ssl.SSLParameters
-dontwarn org.openjsse.javax.net.ssl.SSLSocket
-dontwarn org.openjsse.net.ssl.OpenJSSE
-dontwarn unified.vpn.sdk.HydraConnectionState
-keep class * extends unified.vpn.sdk.Daemon {
public <init>(...);
}
-dontwarn unified.vpn.sdk.KeyValueStorageImpl
-keep public class * extends unified.vpn.sdk.NetworkProbeFactory {
public <init>(...);
}
-keep class unified.vpn.sdk.PingService { *; }
-keep class unified.vpn.sdk.PingResult { *; }
# This dnsjava class uses old Sun API
-dontnote org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
-dontwarn org.xbill.DNS.spi.DNSJavaNameServiceDescriptor
-keepclassmembers class org.xbill.DNS.Lookup {
java.util.Map defaultCaches;
org.xbill.DNS.Name[] defaultSearchPath;
int defaultNdots;
}
-keep class * extends unified.vpn.sdk.WireguardPingJobFactory {
public <init>(...);
}
-keepclassmembers class com.wireguard.** { *; }
-keepclassmembers class unified.vpn.sdk.HydraTransport$ApiHeaderListener {
*** protect(...);
*** onHdr(...);
}
-keep class com.anchorfree.hdr.** {*;}
-keep public class * extends unified.vpn.sdk.VpnException {
*;
}
-keep public class * extends unified.vpn.sdk.CaptivePortalChecker {
public <init>(...);
}
-keep public class * extends unified.vpn.sdk.TransportFactory {
public <init>(...);
}
-keep class * extends unified.vpn.sdk.ReconnectExceptionHandler {
public <init>(...);
}
Setting the VPN Process Name
To set a custom process name for the VPN, add the following string resource to your source file:
// Notification to be displayed when VPN is connectedbuilder.inConnected("Title","Message");//Notification to be displayed when VPN is not connectedbuilder.inIdle("Title","Message");// Notification to be displayed when VPN is connectingbuilder.inConnecting("Title","Message");// Notification to be displayed when VPN is paused (waiting for network connection)builder.inPause("Title","Message");// Notification to be displayed if Client Network List feature is usedbuilder.inCnl("Title","Message");
Notification Message and Title Fallback
By default, the SDK displays notification for the CONNECTED and PAUSED states.
If inConnected was not called, it will try to use value set with title message
If NotificationConfig.Builder.title was not set, it will use App name as in launcher
If inConnected was not called, it will try to use string resource default_notification_connected_message
If inPause was not called, it will try to use string resource default_notification_paused_message
Notification Click Intent
To configure action when a user clicks a notification, use the clickAction method. You must have an Activity responding to the specified action. The action will be used to create an Intent. If clickAction is not specified, the SDK will open the application launch activity on notification click.
In the intent extras, the SDK will set a boolean value UnifiedSDKNotificationManager.EXTRA_NOTIFICATION as true.
To handle the click action, register intent-filter with your activity: