An API to handle Terracotta Android. Unlike normal JNI bindings, relocating this class to another package is supported. State Definition For Android platform, developers must invoke #initialize with a VpnServiceCallback to initialize the rust backend. The
| 55 | * <p>A RuntimeException will be thrown if an error occured in native level.</p> |
| 56 | */ |
| 57 | public final class TerracottaAndroidAPI { |
| 58 | /** |
| 59 | * <p>Callback for receiving VpnService Requests</p> |
| 60 | * |
| 61 | * <p>When receiving one, {@link #getPendingVpnServiceRequest()} is available to get the pending request. |
| 62 | * Developer must make sure either {@link VpnServiceRequest#startVpnService} or {@link VpnServiceRequest#reject()} is invoked, |
| 63 | * or Terracotta would stuck and EasyTier cannot submit a new VpnService Request.</p> |
| 64 | * |
| 65 | * @implNote The VpnServiceRequest must be fulfilled in 30 seconds, or it will be considered as timeout. |
| 66 | */ |
| 67 | public interface VpnServiceCallback { |
| 68 | void onStartVpnService(); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * <p>A VpnService Request submitted by Terracotta. See {@link VpnServiceCallback}</p> |
| 73 | */ |
| 74 | public interface VpnServiceRequest { |
| 75 | /** |
| 76 | * Create a Vpn Connection and fulfill the VpnService Request. |
| 77 | * |
| 78 | * @param builder A pre-configured VpnService builder. |
| 79 | * @return The established Vpn Connection. Developers must close this file descriptor after EasyTier exits. |
| 80 | * @throws RuntimeException if {@link VpnService.Builder#establish()} returns null. |
| 81 | * @implNote Developers is able to configure the builder before passing it into Terracotta |
| 82 | * to fully-custom the connection. |
| 83 | */ |
| 84 | ParcelFileDescriptor startVpnService(VpnService.Builder builder); |
| 85 | |
| 86 | /** |
| 87 | * <p>Reject the VpnServiceRequest.</p> |
| 88 | */ |
| 89 | void reject(); |
| 90 | } |
| 91 | |
| 92 | /** |
| 93 | * <p>Metadata of Terracotta Android</p> |
| 94 | */ |
| 95 | public static final class Metadata { |
| 96 | private final String terracottaVersion; |
| 97 | |
| 98 | private final long terracottaCompileTime; |
| 99 | |
| 100 | private final String easyTierVersion; |
| 101 | |
| 102 | private Metadata(String terracottaVersion, long terracottaCompileTime, String easyTierVersion) { |
| 103 | this.terracottaVersion = terracottaVersion; |
| 104 | this.terracottaCompileTime = terracottaCompileTime; |
| 105 | this.easyTierVersion = easyTierVersion; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * @return Terracotta Android version. |
| 110 | */ |
| 111 | public String getTerracottaVersion() { |
| 112 | return terracottaVersion; |
| 113 | } |
| 114 |
nothing calls this directly
no test coverage detected
searching dependent graphs…