Psi.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. // Java Package psi is a proxy for talking to a Go program.
  2. // gobind -lang=java github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary/psi
  3. //
  4. // File is generated by gobind. Do not edit.
  5. package go.psi;
  6. import go.Seq;
  7. public abstract class Psi {
  8. private Psi() {} // uninstantiable
  9. public interface PsiphonProvider extends go.Seq.Object {
  10. public void BindToDevice(long fileDescriptor) throws Exception;
  11. public long HasNetworkConnectivity();
  12. public void Notice(String noticeJSON);
  13. public static abstract class Stub implements PsiphonProvider {
  14. static final String DESCRIPTOR = "go.psi.PsiphonProvider";
  15. private final go.Seq.Ref ref;
  16. public Stub() {
  17. ref = go.Seq.createRef(this);
  18. }
  19. public go.Seq.Ref ref() { return ref; }
  20. public void call(int code, go.Seq in, go.Seq out) {
  21. switch (code) {
  22. case Proxy.CALL_BindToDevice: {
  23. long param_fileDescriptor = in.readInt();
  24. try {
  25. this.BindToDevice(param_fileDescriptor);
  26. out.writeUTF16(null);
  27. } catch (Exception e) {
  28. out.writeUTF16(e.getMessage());
  29. }
  30. return;
  31. }
  32. case Proxy.CALL_HasNetworkConnectivity: {
  33. long result = this.HasNetworkConnectivity();
  34. out.writeInt(result);
  35. return;
  36. }
  37. case Proxy.CALL_Notice: {
  38. String param_noticeJSON = in.readUTF16();
  39. this.Notice(param_noticeJSON);
  40. return;
  41. }
  42. default:
  43. throw new RuntimeException("unknown code: "+ code);
  44. }
  45. }
  46. }
  47. static final class Proxy implements PsiphonProvider {
  48. static final String DESCRIPTOR = Stub.DESCRIPTOR;
  49. private go.Seq.Ref ref;
  50. Proxy(go.Seq.Ref ref) { this.ref = ref; }
  51. public go.Seq.Ref ref() { return ref; }
  52. public void call(int code, go.Seq in, go.Seq out) {
  53. throw new RuntimeException("cycle: cannot call proxy");
  54. }
  55. public void BindToDevice(long fileDescriptor) throws Exception {
  56. go.Seq _in = new go.Seq();
  57. go.Seq _out = new go.Seq();
  58. _in.writeRef(ref);
  59. _in.writeInt(fileDescriptor);
  60. Seq.send(DESCRIPTOR, CALL_BindToDevice, _in, _out);
  61. String _err = _out.readUTF16();
  62. if (_err != null) {
  63. throw new Exception(_err);
  64. }
  65. }
  66. public long HasNetworkConnectivity() {
  67. go.Seq _in = new go.Seq();
  68. go.Seq _out = new go.Seq();
  69. long _result;
  70. _in.writeRef(ref);
  71. Seq.send(DESCRIPTOR, CALL_HasNetworkConnectivity, _in, _out);
  72. _result = _out.readInt();
  73. return _result;
  74. }
  75. public void Notice(String noticeJSON) {
  76. go.Seq _in = new go.Seq();
  77. go.Seq _out = new go.Seq();
  78. _in.writeRef(ref);
  79. _in.writeUTF16(noticeJSON);
  80. Seq.send(DESCRIPTOR, CALL_Notice, _in, _out);
  81. }
  82. static final int CALL_BindToDevice = 0x10a;
  83. static final int CALL_HasNetworkConnectivity = 0x20a;
  84. static final int CALL_Notice = 0x30a;
  85. }
  86. }
  87. public static void Start(String configJson, String embeddedServerEntryList, PsiphonProvider provider) throws Exception {
  88. go.Seq _in = new go.Seq();
  89. go.Seq _out = new go.Seq();
  90. _in.writeUTF16(configJson);
  91. _in.writeUTF16(embeddedServerEntryList);
  92. _in.writeRef(provider.ref());
  93. Seq.send(DESCRIPTOR, CALL_Start, _in, _out);
  94. String _err = _out.readUTF16();
  95. if (_err != null) {
  96. throw new Exception(_err);
  97. }
  98. }
  99. public static void Stop() {
  100. go.Seq _in = new go.Seq();
  101. go.Seq _out = new go.Seq();
  102. Seq.send(DESCRIPTOR, CALL_Stop, _in, _out);
  103. }
  104. private static final int CALL_Start = 1;
  105. private static final int CALL_Stop = 2;
  106. private static final String DESCRIPTOR = "psi";
  107. }