Platform.smali 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. .class public Lokhttp3/internal/platform/Platform;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # static fields
  5. .field public static final INFO:I = 0x4
  6. .field private static final PLATFORM:Lokhttp3/internal/platform/Platform;
  7. .field public static final WARN:I = 0x5
  8. .field private static final logger:Ljava/util/logging/Logger;
  9. # direct methods
  10. .method static constructor <clinit>()V
  11. .locals 1
  12. invoke-static {}, Lokhttp3/internal/platform/Platform;->findPlatform()Lokhttp3/internal/platform/Platform;
  13. move-result-object v0
  14. sput-object v0, Lokhttp3/internal/platform/Platform;->PLATFORM:Lokhttp3/internal/platform/Platform;
  15. const-class v0, Lokhttp3/OkHttpClient;
  16. invoke-virtual {v0}, Ljava/lang/Class;->getName()Ljava/lang/String;
  17. move-result-object v0
  18. invoke-static {v0}, Ljava/util/logging/Logger;->getLogger(Ljava/lang/String;)Ljava/util/logging/Logger;
  19. move-result-object v0
  20. sput-object v0, Lokhttp3/internal/platform/Platform;->logger:Ljava/util/logging/Logger;
  21. return-void
  22. .end method
  23. .method public constructor <init>()V
  24. .locals 0
  25. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  26. return-void
  27. .end method
  28. .method public static alpnProtocolNames(Ljava/util/List;)Ljava/util/List;
  29. .locals 5
  30. .annotation system Ldalvik/annotation/Signature;
  31. value = {
  32. "(",
  33. "Ljava/util/List<",
  34. "Lokhttp3/Protocol;",
  35. ">;)",
  36. "Ljava/util/List<",
  37. "Ljava/lang/String;",
  38. ">;"
  39. }
  40. .end annotation
  41. new-instance v0, Ljava/util/ArrayList;
  42. invoke-interface {p0}, Ljava/util/List;->size()I
  43. move-result v1
  44. invoke-direct {v0, v1}, Ljava/util/ArrayList;-><init>(I)V
  45. invoke-interface {p0}, Ljava/util/List;->size()I
  46. move-result v1
  47. const/4 v2, 0x0
  48. :goto_0
  49. if-ge v2, v1, :cond_1
  50. invoke-interface {p0, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;
  51. move-result-object v3
  52. check-cast v3, Lokhttp3/Protocol;
  53. sget-object v4, Lokhttp3/Protocol;->HTTP_1_0:Lokhttp3/Protocol;
  54. if-ne v3, v4, :cond_0
  55. goto :goto_1
  56. :cond_0
  57. invoke-virtual {v3}, Lokhttp3/Protocol;->toString()Ljava/lang/String;
  58. move-result-object v3
  59. invoke-interface {v0, v3}, Ljava/util/List;->add(Ljava/lang/Object;)Z
  60. :goto_1
  61. add-int/lit8 v2, v2, 0x1
  62. goto :goto_0
  63. :cond_1
  64. return-object v0
  65. .end method
  66. .method static concatLengthPrefixed(Ljava/util/List;)[B
  67. .locals 5
  68. .annotation system Ldalvik/annotation/Signature;
  69. value = {
  70. "(",
  71. "Ljava/util/List<",
  72. "Lokhttp3/Protocol;",
  73. ">;)[B"
  74. }
  75. .end annotation
  76. new-instance v0, Lokio/Buffer;
  77. invoke-direct {v0}, Lokio/Buffer;-><init>()V
  78. invoke-interface {p0}, Ljava/util/List;->size()I
  79. move-result v1
  80. const/4 v2, 0x0
  81. :goto_0
  82. if-ge v2, v1, :cond_1
  83. invoke-interface {p0, v2}, Ljava/util/List;->get(I)Ljava/lang/Object;
  84. move-result-object v3
  85. check-cast v3, Lokhttp3/Protocol;
  86. sget-object v4, Lokhttp3/Protocol;->HTTP_1_0:Lokhttp3/Protocol;
  87. if-ne v3, v4, :cond_0
  88. goto :goto_1
  89. :cond_0
  90. invoke-virtual {v3}, Lokhttp3/Protocol;->toString()Ljava/lang/String;
  91. move-result-object v4
  92. invoke-virtual {v4}, Ljava/lang/String;->length()I
  93. move-result v4
  94. invoke-virtual {v0, v4}, Lokio/Buffer;->writeByte(I)Lokio/Buffer;
  95. invoke-virtual {v3}, Lokhttp3/Protocol;->toString()Ljava/lang/String;
  96. move-result-object v3
  97. invoke-virtual {v0, v3}, Lokio/Buffer;->writeUtf8(Ljava/lang/String;)Lokio/Buffer;
  98. :goto_1
  99. add-int/lit8 v2, v2, 0x1
  100. goto :goto_0
  101. :cond_1
  102. invoke-virtual {v0}, Lokio/Buffer;->readByteArray()[B
  103. move-result-object p0
  104. return-object p0
  105. .end method
  106. .method private static findPlatform()Lokhttp3/internal/platform/Platform;
  107. .locals 1
  108. invoke-static {}, Lokhttp3/internal/platform/AndroidPlatform;->buildIfSupported()Lokhttp3/internal/platform/Platform;
  109. move-result-object v0
  110. if-eqz v0, :cond_0
  111. return-object v0
  112. :cond_0
  113. invoke-static {}, Lokhttp3/internal/platform/Jdk9Platform;->buildIfSupported()Lokhttp3/internal/platform/Jdk9Platform;
  114. move-result-object v0
  115. if-eqz v0, :cond_1
  116. return-object v0
  117. :cond_1
  118. invoke-static {}, Lokhttp3/internal/platform/JdkWithJettyBootPlatform;->buildIfSupported()Lokhttp3/internal/platform/Platform;
  119. move-result-object v0
  120. if-eqz v0, :cond_2
  121. return-object v0
  122. :cond_2
  123. new-instance v0, Lokhttp3/internal/platform/Platform;
  124. invoke-direct {v0}, Lokhttp3/internal/platform/Platform;-><init>()V
  125. return-object v0
  126. .end method
  127. .method public static get()Lokhttp3/internal/platform/Platform;
  128. .locals 1
  129. sget-object v0, Lokhttp3/internal/platform/Platform;->PLATFORM:Lokhttp3/internal/platform/Platform;
  130. return-object v0
  131. .end method
  132. .method static readFieldOrNull(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
  133. .locals 5
  134. .annotation system Ldalvik/annotation/Signature;
  135. value = {
  136. "<T:",
  137. "Ljava/lang/Object;",
  138. ">(",
  139. "Ljava/lang/Object;",
  140. "Ljava/lang/Class<",
  141. "TT;>;",
  142. "Ljava/lang/String;",
  143. ")TT;"
  144. }
  145. .end annotation
  146. const-class v0, Ljava/lang/Object;
  147. invoke-virtual {p0}, Ljava/lang/Object;->getClass()Ljava/lang/Class;
  148. move-result-object v1
  149. :goto_0
  150. const/4 v2, 0x0
  151. if-eq v1, v0, :cond_2
  152. :try_start_0
  153. invoke-virtual {v1, p2}, Ljava/lang/Class;->getDeclaredField(Ljava/lang/String;)Ljava/lang/reflect/Field;
  154. move-result-object v3
  155. const/4 v4, 0x1
  156. invoke-virtual {v3, v4}, Ljava/lang/reflect/Field;->setAccessible(Z)V
  157. invoke-virtual {v3, p0}, Ljava/lang/reflect/Field;->get(Ljava/lang/Object;)Ljava/lang/Object;
  158. move-result-object v3
  159. if-eqz v3, :cond_1
  160. invoke-virtual {p1, v3}, Ljava/lang/Class;->isInstance(Ljava/lang/Object;)Z
  161. move-result v4
  162. if-nez v4, :cond_0
  163. goto :goto_1
  164. :cond_0
  165. invoke-virtual {p1, v3}, Ljava/lang/Class;->cast(Ljava/lang/Object;)Ljava/lang/Object;
  166. move-result-object p0
  167. :try_end_0
  168. .catch Ljava/lang/NoSuchFieldException; {:try_start_0 .. :try_end_0} :catch_1
  169. .catch Ljava/lang/IllegalAccessException; {:try_start_0 .. :try_end_0} :catch_0
  170. return-object p0
  171. :cond_1
  172. :goto_1
  173. return-object v2
  174. :catch_0
  175. new-instance p0, Ljava/lang/AssertionError;
  176. invoke-direct {p0}, Ljava/lang/AssertionError;-><init>()V
  177. throw p0
  178. :catch_1
  179. invoke-virtual {v1}, Ljava/lang/Class;->getSuperclass()Ljava/lang/Class;
  180. move-result-object v1
  181. goto :goto_0
  182. :cond_2
  183. const-string v1, "delegate"
  184. invoke-virtual {p2, v1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  185. move-result v3
  186. if-nez v3, :cond_3
  187. invoke-static {p0, v0, v1}, Lokhttp3/internal/platform/Platform;->readFieldOrNull(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
  188. move-result-object p0
  189. if-eqz p0, :cond_3
  190. invoke-static {p0, p1, p2}, Lokhttp3/internal/platform/Platform;->readFieldOrNull(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
  191. move-result-object p0
  192. return-object p0
  193. :cond_3
  194. return-object v2
  195. .end method
  196. # virtual methods
  197. .method public afterHandshake(Ljavax/net/ssl/SSLSocket;)V
  198. .locals 0
  199. return-void
  200. .end method
  201. .method public buildCertificateChainCleaner(Ljavax/net/ssl/X509TrustManager;)Lokhttp3/internal/tls/CertificateChainCleaner;
  202. .locals 1
  203. new-instance v0, Lokhttp3/internal/tls/BasicCertificateChainCleaner;
  204. invoke-virtual {p0, p1}, Lokhttp3/internal/platform/Platform;->buildTrustRootIndex(Ljavax/net/ssl/X509TrustManager;)Lokhttp3/internal/tls/TrustRootIndex;
  205. move-result-object p1
  206. invoke-direct {v0, p1}, Lokhttp3/internal/tls/BasicCertificateChainCleaner;-><init>(Lokhttp3/internal/tls/TrustRootIndex;)V
  207. return-object v0
  208. .end method
  209. .method public buildTrustRootIndex(Ljavax/net/ssl/X509TrustManager;)Lokhttp3/internal/tls/TrustRootIndex;
  210. .locals 1
  211. new-instance v0, Lokhttp3/internal/tls/BasicTrustRootIndex;
  212. invoke-interface {p1}, Ljavax/net/ssl/X509TrustManager;->getAcceptedIssuers()[Ljava/security/cert/X509Certificate;
  213. move-result-object p1
  214. invoke-direct {v0, p1}, Lokhttp3/internal/tls/BasicTrustRootIndex;-><init>([Ljava/security/cert/X509Certificate;)V
  215. return-object v0
  216. .end method
  217. .method public configureTlsExtensions(Ljavax/net/ssl/SSLSocket;Ljava/lang/String;Ljava/util/List;)V
  218. .locals 0
  219. .annotation system Ldalvik/annotation/Signature;
  220. value = {
  221. "(",
  222. "Ljavax/net/ssl/SSLSocket;",
  223. "Ljava/lang/String;",
  224. "Ljava/util/List<",
  225. "Lokhttp3/Protocol;",
  226. ">;)V"
  227. }
  228. .end annotation
  229. return-void
  230. .end method
  231. .method public connectSocket(Ljava/net/Socket;Ljava/net/InetSocketAddress;I)V
  232. .locals 0
  233. .annotation system Ldalvik/annotation/Throws;
  234. value = {
  235. Ljava/io/IOException;
  236. }
  237. .end annotation
  238. invoke-virtual {p1, p2, p3}, Ljava/net/Socket;->connect(Ljava/net/SocketAddress;I)V
  239. return-void
  240. .end method
  241. .method public getPrefix()Ljava/lang/String;
  242. .locals 1
  243. const-string v0, "OkHttp"
  244. return-object v0
  245. .end method
  246. .method public getSelectedProtocol(Ljavax/net/ssl/SSLSocket;)Ljava/lang/String;
  247. .locals 0
  248. const/4 p1, 0x0
  249. return-object p1
  250. .end method
  251. .method public getStackTraceForCloseable(Ljava/lang/String;)Ljava/lang/Object;
  252. .locals 2
  253. sget-object v0, Lokhttp3/internal/platform/Platform;->logger:Ljava/util/logging/Logger;
  254. sget-object v1, Ljava/util/logging/Level;->FINE:Ljava/util/logging/Level;
  255. invoke-virtual {v0, v1}, Ljava/util/logging/Logger;->isLoggable(Ljava/util/logging/Level;)Z
  256. move-result v0
  257. if-eqz v0, :cond_0
  258. new-instance v0, Ljava/lang/Throwable;
  259. invoke-direct {v0, p1}, Ljava/lang/Throwable;-><init>(Ljava/lang/String;)V
  260. return-object v0
  261. :cond_0
  262. const/4 p1, 0x0
  263. return-object p1
  264. .end method
  265. .method public isCleartextTrafficPermitted(Ljava/lang/String;)Z
  266. .locals 0
  267. const/4 p1, 0x1
  268. return p1
  269. .end method
  270. .method public log(ILjava/lang/String;Ljava/lang/Throwable;)V
  271. .locals 1
  272. const/4 v0, 0x5
  273. if-ne p1, v0, :cond_0
  274. sget-object p1, Ljava/util/logging/Level;->WARNING:Ljava/util/logging/Level;
  275. goto :goto_0
  276. :cond_0
  277. sget-object p1, Ljava/util/logging/Level;->INFO:Ljava/util/logging/Level;
  278. :goto_0
  279. sget-object v0, Lokhttp3/internal/platform/Platform;->logger:Ljava/util/logging/Logger;
  280. invoke-virtual {v0, p1, p2, p3}, Ljava/util/logging/Logger;->log(Ljava/util/logging/Level;Ljava/lang/String;Ljava/lang/Throwable;)V
  281. return-void
  282. .end method
  283. .method public logCloseableLeak(Ljava/lang/String;Ljava/lang/Object;)V
  284. .locals 1
  285. if-nez p2, :cond_0
  286. new-instance v0, Ljava/lang/StringBuilder;
  287. invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
  288. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  289. const-string p1, " To see where this was allocated, set the OkHttpClient logger level to FINE: Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);"
  290. invoke-virtual {v0, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  291. invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  292. move-result-object p1
  293. :cond_0
  294. const/4 v0, 0x5
  295. check-cast p2, Ljava/lang/Throwable;
  296. invoke-virtual {p0, v0, p1, p2}, Lokhttp3/internal/platform/Platform;->log(ILjava/lang/String;Ljava/lang/Throwable;)V
  297. return-void
  298. .end method
  299. .method public trustManager(Ljavax/net/ssl/SSLSocketFactory;)Ljavax/net/ssl/X509TrustManager;
  300. .locals 3
  301. const-string v0, "sun.security.ssl.SSLContextImpl"
  302. const/4 v1, 0x0
  303. :try_start_0
  304. invoke-static {v0}, Ljava/lang/Class;->forName(Ljava/lang/String;)Ljava/lang/Class;
  305. move-result-object v0
  306. const-string v2, "context"
  307. invoke-static {p1, v0, v2}, Lokhttp3/internal/platform/Platform;->readFieldOrNull(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
  308. move-result-object p1
  309. if-nez p1, :cond_0
  310. return-object v1
  311. :cond_0
  312. const-class v0, Ljavax/net/ssl/X509TrustManager;
  313. const-string v2, "trustManager"
  314. invoke-static {p1, v0, v2}, Lokhttp3/internal/platform/Platform;->readFieldOrNull(Ljava/lang/Object;Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Object;
  315. move-result-object p1
  316. check-cast p1, Ljavax/net/ssl/X509TrustManager;
  317. :try_end_0
  318. .catch Ljava/lang/ClassNotFoundException; {:try_start_0 .. :try_end_0} :catch_0
  319. return-object p1
  320. :catch_0
  321. return-object v1
  322. .end method