ConnectionSpecSelector.smali 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. .class public final Lokhttp3/internal/connection/ConnectionSpecSelector;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # instance fields
  5. .field private final connectionSpecs:Ljava/util/List;
  6. .annotation system Ldalvik/annotation/Signature;
  7. value = {
  8. "Ljava/util/List<",
  9. "Lokhttp3/ConnectionSpec;",
  10. ">;"
  11. }
  12. .end annotation
  13. .end field
  14. .field private isFallback:Z
  15. .field private isFallbackPossible:Z
  16. .field private nextModeIndex:I
  17. # direct methods
  18. .method public constructor <init>(Ljava/util/List;)V
  19. .locals 1
  20. .annotation system Ldalvik/annotation/Signature;
  21. value = {
  22. "(",
  23. "Ljava/util/List<",
  24. "Lokhttp3/ConnectionSpec;",
  25. ">;)V"
  26. }
  27. .end annotation
  28. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  29. const/4 v0, 0x0
  30. iput v0, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->nextModeIndex:I
  31. iput-object p1, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->connectionSpecs:Ljava/util/List;
  32. return-void
  33. .end method
  34. .method private isFallbackPossible(Ljavax/net/ssl/SSLSocket;)Z
  35. .locals 2
  36. iget v0, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->nextModeIndex:I
  37. :goto_0
  38. iget-object v1, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->connectionSpecs:Ljava/util/List;
  39. invoke-interface {v1}, Ljava/util/List;->size()I
  40. move-result v1
  41. if-ge v0, v1, :cond_1
  42. iget-object v1, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->connectionSpecs:Ljava/util/List;
  43. invoke-interface {v1, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;
  44. move-result-object v1
  45. check-cast v1, Lokhttp3/ConnectionSpec;
  46. invoke-virtual {v1, p1}, Lokhttp3/ConnectionSpec;->isCompatible(Ljavax/net/ssl/SSLSocket;)Z
  47. move-result v1
  48. if-eqz v1, :cond_0
  49. const/4 p1, 0x1
  50. return p1
  51. :cond_0
  52. add-int/lit8 v0, v0, 0x1
  53. goto :goto_0
  54. :cond_1
  55. const/4 p1, 0x0
  56. return p1
  57. .end method
  58. # virtual methods
  59. .method public configureSecureSocket(Ljavax/net/ssl/SSLSocket;)Lokhttp3/ConnectionSpec;
  60. .locals 4
  61. .annotation system Ldalvik/annotation/Throws;
  62. value = {
  63. Ljava/io/IOException;
  64. }
  65. .end annotation
  66. iget v0, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->nextModeIndex:I
  67. iget-object v1, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->connectionSpecs:Ljava/util/List;
  68. invoke-interface {v1}, Ljava/util/List;->size()I
  69. move-result v1
  70. :cond_0
  71. if-ge v0, v1, :cond_1
  72. iget-object v2, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->connectionSpecs:Ljava/util/List;
  73. invoke-interface {v2, v0}, Ljava/util/List;->get(I)Ljava/lang/Object;
  74. move-result-object v2
  75. check-cast v2, Lokhttp3/ConnectionSpec;
  76. invoke-virtual {v2, p1}, Lokhttp3/ConnectionSpec;->isCompatible(Ljavax/net/ssl/SSLSocket;)Z
  77. move-result v3
  78. add-int/lit8 v0, v0, 0x1
  79. if-eqz v3, :cond_0
  80. iput v0, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->nextModeIndex:I
  81. goto :goto_0
  82. :cond_1
  83. const/4 v2, 0x0
  84. :goto_0
  85. if-eqz v2, :cond_2
  86. invoke-direct {p0, p1}, Lokhttp3/internal/connection/ConnectionSpecSelector;->isFallbackPossible(Ljavax/net/ssl/SSLSocket;)Z
  87. move-result v0
  88. iput-boolean v0, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->isFallbackPossible:Z
  89. sget-object v0, Lokhttp3/internal/Internal;->instance:Lokhttp3/internal/Internal;
  90. iget-boolean v1, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->isFallback:Z
  91. invoke-virtual {v0, v2, p1, v1}, Lokhttp3/internal/Internal;->apply(Lokhttp3/ConnectionSpec;Ljavax/net/ssl/SSLSocket;Z)V
  92. return-object v2
  93. :cond_2
  94. new-instance v0, Ljava/net/UnknownServiceException;
  95. new-instance v1, Ljava/lang/StringBuilder;
  96. invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
  97. const-string v2, "Unable to find acceptable protocols. isFallback="
  98. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  99. iget-boolean v2, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->isFallback:Z
  100. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Z)Ljava/lang/StringBuilder;
  101. const-string v2, ", modes="
  102. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  103. iget-object v2, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->connectionSpecs:Ljava/util/List;
  104. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
  105. const-string v2, ", supported protocols="
  106. invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  107. invoke-virtual {p1}, Ljavax/net/ssl/SSLSocket;->getEnabledProtocols()[Ljava/lang/String;
  108. move-result-object p1
  109. invoke-static {p1}, Ljava/util/Arrays;->toString([Ljava/lang/Object;)Ljava/lang/String;
  110. move-result-object p1
  111. invoke-virtual {v1, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
  112. invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
  113. move-result-object p1
  114. invoke-direct {v0, p1}, Ljava/net/UnknownServiceException;-><init>(Ljava/lang/String;)V
  115. goto :goto_2
  116. :goto_1
  117. throw v0
  118. :goto_2
  119. goto :goto_1
  120. .end method
  121. .method public connectionFailed(Ljava/io/IOException;)Z
  122. .locals 4
  123. const/4 v0, 0x1
  124. iput-boolean v0, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->isFallback:Z
  125. iget-boolean v1, p0, Lokhttp3/internal/connection/ConnectionSpecSelector;->isFallbackPossible:Z
  126. const/4 v2, 0x0
  127. if-nez v1, :cond_0
  128. return v2
  129. :cond_0
  130. instance-of v1, p1, Ljava/net/ProtocolException;
  131. if-eqz v1, :cond_1
  132. return v2
  133. :cond_1
  134. instance-of v1, p1, Ljava/io/InterruptedIOException;
  135. if-eqz v1, :cond_2
  136. return v2
  137. :cond_2
  138. instance-of v1, p1, Ljavax/net/ssl/SSLHandshakeException;
  139. if-eqz v1, :cond_3
  140. invoke-virtual {p1}, Ljava/io/IOException;->getCause()Ljava/lang/Throwable;
  141. move-result-object v3
  142. instance-of v3, v3, Ljava/security/cert/CertificateException;
  143. if-eqz v3, :cond_3
  144. return v2
  145. :cond_3
  146. instance-of v3, p1, Ljavax/net/ssl/SSLPeerUnverifiedException;
  147. if-eqz v3, :cond_4
  148. return v2
  149. :cond_4
  150. if-nez v1, :cond_6
  151. instance-of p1, p1, Ljavax/net/ssl/SSLProtocolException;
  152. if-eqz p1, :cond_5
  153. goto :goto_0
  154. :cond_5
  155. const/4 v0, 0x0
  156. :cond_6
  157. :goto_0
  158. return v0
  159. .end method