ResponseBody$BomAwareReader.smali 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. .class final Lokhttp3/ResponseBody$BomAwareReader;
  2. .super Ljava/io/Reader;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/ResponseBody;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x18
  10. name = "BomAwareReader"
  11. .end annotation
  12. # instance fields
  13. .field private final charset:Ljava/nio/charset/Charset;
  14. .field private closed:Z
  15. .field private delegate:Ljava/io/Reader;
  16. .field private final source:Lokio/BufferedSource;
  17. # direct methods
  18. .method constructor <init>(Lokio/BufferedSource;Ljava/nio/charset/Charset;)V
  19. .locals 0
  20. invoke-direct {p0}, Ljava/io/Reader;-><init>()V
  21. iput-object p1, p0, Lokhttp3/ResponseBody$BomAwareReader;->source:Lokio/BufferedSource;
  22. iput-object p2, p0, Lokhttp3/ResponseBody$BomAwareReader;->charset:Ljava/nio/charset/Charset;
  23. return-void
  24. .end method
  25. # virtual methods
  26. .method public close()V
  27. .locals 1
  28. .annotation system Ldalvik/annotation/Throws;
  29. value = {
  30. Ljava/io/IOException;
  31. }
  32. .end annotation
  33. const/4 v0, 0x1
  34. iput-boolean v0, p0, Lokhttp3/ResponseBody$BomAwareReader;->closed:Z
  35. iget-object v0, p0, Lokhttp3/ResponseBody$BomAwareReader;->delegate:Ljava/io/Reader;
  36. if-eqz v0, :cond_0
  37. invoke-virtual {v0}, Ljava/io/Reader;->close()V
  38. goto :goto_0
  39. :cond_0
  40. iget-object v0, p0, Lokhttp3/ResponseBody$BomAwareReader;->source:Lokio/BufferedSource;
  41. invoke-interface {v0}, Lokio/Source;->close()V
  42. :goto_0
  43. return-void
  44. .end method
  45. .method public read([CII)I
  46. .locals 3
  47. .annotation system Ldalvik/annotation/Throws;
  48. value = {
  49. Ljava/io/IOException;
  50. }
  51. .end annotation
  52. iget-boolean v0, p0, Lokhttp3/ResponseBody$BomAwareReader;->closed:Z
  53. if-nez v0, :cond_1
  54. iget-object v0, p0, Lokhttp3/ResponseBody$BomAwareReader;->delegate:Ljava/io/Reader;
  55. if-nez v0, :cond_0
  56. iget-object v0, p0, Lokhttp3/ResponseBody$BomAwareReader;->source:Lokio/BufferedSource;
  57. iget-object v1, p0, Lokhttp3/ResponseBody$BomAwareReader;->charset:Ljava/nio/charset/Charset;
  58. invoke-static {v0, v1}, Lokhttp3/internal/Util;->bomAwareCharset(Lokio/BufferedSource;Ljava/nio/charset/Charset;)Ljava/nio/charset/Charset;
  59. move-result-object v0
  60. new-instance v1, Ljava/io/InputStreamReader;
  61. iget-object v2, p0, Lokhttp3/ResponseBody$BomAwareReader;->source:Lokio/BufferedSource;
  62. invoke-interface {v2}, Lokio/BufferedSource;->inputStream()Ljava/io/InputStream;
  63. move-result-object v2
  64. invoke-direct {v1, v2, v0}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;Ljava/nio/charset/Charset;)V
  65. iput-object v1, p0, Lokhttp3/ResponseBody$BomAwareReader;->delegate:Ljava/io/Reader;
  66. move-object v0, v1
  67. :cond_0
  68. invoke-virtual {v0, p1, p2, p3}, Ljava/io/Reader;->read([CII)I
  69. move-result p1
  70. return p1
  71. :cond_1
  72. new-instance p1, Ljava/io/IOException;
  73. const-string p2, "Stream closed"
  74. invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  75. throw p1
  76. .end method