ProtocolUtil.smali
.class public Lcn/jiguang/api/utils/ProtocolUtil;
.super Ljava/lang/Object;
# static fields
.field private static final ENCODING_UTF_8:Ljava/lang/String; = "UTF-8"
.field private static final TAG:Ljava/lang/String; = "ProtocolUtil"
# direct methods
.method public constructor <init>()V
.registers 1
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
return-void
.end method
.method public static fillIntData([BII)V
.registers 6
invoke-static {p1}, Lcn/jiguang/api/utils/ProtocolUtil;->int2ByteArray(I)[B
move-result-object v0
const/4 v1, 0x0
const/4 v2, 0x4
invoke-static {v0, v1, p0, p2, v2}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
return-void
.end method
.method public static fillStringData([BLjava/lang/String;I)V
.registers 6
invoke-virtual {p1}, Ljava/lang/String;->getBytes()[B
move-result-object v0
const/4 v1, 0x0
array-length v2, v0
invoke-static {v0, v1, p0, p2, v2}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
return-void
.end method
.method public static fixedStringToBytes(Ljava/lang/String;I)[B
.registers 6
const/4 v2, 0x4
const/4 v3, 0x0
if-eqz p0, :cond_c
const-string v0, ""
invoke-virtual {v0, p0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_12
:cond_c
new-array v0, v2, [B
fill-array-data v0, :array_32
:goto_11
return-object v0
:cond_12
const/4 v0, 0x0
:try_start_13
const-string v1, "UTF-8"
invoke-virtual {p0, v1}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B
:try_end_18
.catch Ljava/io/UnsupportedEncodingException; {:try_start_13 .. :try_end_18} :catch_22
move-result-object v0
move-object v1, v0
:goto_1a
if-nez v1, :cond_25
new-array v0, v2, [B
fill-array-data v0, :array_38
goto :goto_11
:catch_22
move-exception v1
move-object v1, v0
goto :goto_1a
:cond_25
invoke-static {p1}, Lcn/jiguang/api/utils/ProtocolUtil;->getDefaultByte(I)[B
move-result-object v0
array-length v2, v1
if-le v2, p1, :cond_30
:goto_2c
invoke-static {v1, v3, v0, v3, p1}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
goto :goto_11
:cond_30
array-length p1, v1
goto :goto_2c
:array_32
.array-data 1
0x0t
0x0t
0x0t
0x0t
.end array-data
:array_38
.array-data 1
0x0t
0x0t
0x0t
0x0t
.end array-data
.end method
.method public static getBytes(Ljava/nio/ByteBuffer;)[B
.registers 4
const/4 v1, 0x0
:try_start_1
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->remaining()I
move-result v0
new-array v0, v0, [B
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->asReadOnlyBuffer()Ljava/nio/ByteBuffer;
move-result-object v2
invoke-virtual {v2}, Ljava/nio/ByteBuffer;->flip()Ljava/nio/Buffer;
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->get([B)Ljava/nio/ByteBuffer;
:try_end_11
.catch Ljava/lang/NegativeArraySizeException; {:try_start_1 .. :try_end_11} :catch_12
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_11} :catch_1c
:goto_11
return-object v0
:catch_12
move-exception v0
const-string v0, "ProtocolUtil"
const-string v2, "[getBytes] - ByteBuffer error."
invoke-static {v0, v2}, Lcn/jiguang/aq/d;->c(Ljava/lang/String;Ljava/lang/String;)V
move-object v0, v1
goto :goto_11
:catch_1c
move-exception v0
move-object v0, v1
goto :goto_11
.end method
.method public static getBytesConsumed(Ljava/nio/ByteBuffer;)[B
.registers 4
const/4 v1, 0x0
:try_start_1
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->remaining()I
move-result v0
new-array v0, v0, [B
invoke-virtual {p0, v0}, Ljava/nio/ByteBuffer;->get([B)Ljava/nio/ByteBuffer;
:try_end_a
.catch Ljava/lang/NegativeArraySizeException; {:try_start_1 .. :try_end_a} :catch_b
.catch Ljava/lang/Exception; {:try_start_1 .. :try_end_a} :catch_15
:goto_a
return-object v0
:catch_b
move-exception v0
const-string v0, "ProtocolUtil"
const-string v2, "[getBytesConsumed] - ByteBuffer error."
invoke-static {v0, v2}, Lcn/jiguang/aq/d;->c(Ljava/lang/String;Ljava/lang/String;)V
move-object v0, v1
goto :goto_a
:catch_15
move-exception v0
move-object v0, v1
goto :goto_a
.end method
.method public static getDefaultByte(I)[B
.registers 4
const/4 v1, 0x0
new-array v2, p0, [B
move v0, v1
:goto_4
if-ge v0, p0, :cond_b
aput-byte v1, v2, v1
add-int/lit8 v0, v0, 0x1
goto :goto_4
:cond_b
return-object v2
.end method
.method public static getString(Ljava/nio/ByteBuffer;I)Ljava/lang/String;
.registers 5
new-array v1, p1, [B
invoke-virtual {p0, v1}, Ljava/nio/ByteBuffer;->get([B)Ljava/nio/ByteBuffer;
:try_start_5
new-instance v0, Ljava/lang/String;
const-string v2, "UTF-8"
invoke-direct {v0, v1, v2}, Ljava/lang/String;-><init>([BLjava/lang/String;)V
:try_end_c
.catch Ljava/io/UnsupportedEncodingException; {:try_start_5 .. :try_end_c} :catch_d
:goto_c
return-object v0
:catch_d
move-exception v0
const/4 v0, 0x0
goto :goto_c
.end method
.method public static getTlv2(Ljava/nio/ByteBuffer;)Ljava/lang/String;
.registers 4
:try_start_0
invoke-virtual {p0}, Ljava/nio/ByteBuffer;->getShort()S
move-result v0
new-array v1, v0, [B
invoke-virtual {p0, v1}, Ljava/nio/ByteBuffer;->get([B)Ljava/nio/ByteBuffer;
new-instance v0, Ljava/lang/String;
const-string v2, "UTF-8"
invoke-direct {v0, v1, v2}, Ljava/lang/String;-><init>([BLjava/lang/String;)V
:try_end_10
.catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_10} :catch_14
.catch Ljava/lang/Exception; {:try_start_0 .. :try_end_10} :catch_11
:goto_10
return-object v0
:catch_11
move-exception v0
:goto_12
const/4 v0, 0x0
goto :goto_10
:catch_14
move-exception v0
goto :goto_12
.end method
.method public static getTlv2(Ljava/nio/ByteBuffer;Lcn/jiguang/api/JResponse;)Ljava/lang/String;
.registers 6
const/4 v0, 0x0
invoke-static {p0, p1}, Lcn/jiguang/api/utils/ByteBufferUtils;->getShort(Ljava/nio/ByteBuffer;Lcn/jiguang/api/JResponse;)S
move-result v1
if-gez v1, :cond_f
const-string v1, "ProtocolUtil"
const-string v2, "[getTlv2] - ByteBuffer error."
invoke-static {v1, v2}, Lcn/jiguang/aq/d;->c(Ljava/lang/String;Ljava/lang/String;)V
:goto_e
return-object v0
:cond_f
new-array v2, v1, [B
invoke-static {p0, v2, p1}, Lcn/jiguang/api/utils/ByteBufferUtils;->get(Ljava/nio/ByteBuffer;[BLcn/jiguang/api/JResponse;)Ljava/nio/ByteBuffer;
:try_start_14
new-instance v1, Ljava/lang/String;
const-string v3, "UTF-8"
invoke-direct {v1, v2, v3}, Ljava/lang/String;-><init>([BLjava/lang/String;)V
:try_end_1b
.catch Ljava/lang/Throwable; {:try_start_14 .. :try_end_1b} :catch_1d
move-object v0, v1
goto :goto_e
:catch_1d
move-exception v1
goto :goto_e
.end method
.method public static int2ByteArray(I)[B
.registers 4
const/4 v0, 0x4
new-array v0, v0, [B
const/4 v1, 0x0
ushr-int/lit8 v2, p0, 0x18
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x1
ushr-int/lit8 v2, p0, 0x10
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x2
ushr-int/lit8 v2, p0, 0x8
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x3
int-to-byte v2, p0
aput-byte v2, v0, v1
return-object v0
.end method
.method public static long2ByteArray(J)[B
.registers 8
const/16 v4, 0x8
new-array v0, v4, [B
const/4 v1, 0x0
const/16 v2, 0x38
ushr-long v2, p0, v2
long-to-int v2, v2
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x1
const/16 v2, 0x30
ushr-long v2, p0, v2
long-to-int v2, v2
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x2
const/16 v2, 0x28
ushr-long v2, p0, v2
long-to-int v2, v2
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x3
const/16 v2, 0x20
ushr-long v2, p0, v2
long-to-int v2, v2
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x4
const/16 v2, 0x18
ushr-long v2, p0, v2
long-to-int v2, v2
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x5
const/16 v2, 0x10
ushr-long v2, p0, v2
long-to-int v2, v2
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x6
ushr-long v2, p0, v4
long-to-int v2, v2
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x7
long-to-int v2, p0
int-to-byte v2, v2
aput-byte v2, v0, v1
return-object v0
.end method
.method public static short2ByteArray(S)[B
.registers 4
const/4 v0, 0x2
new-array v0, v0, [B
const/4 v1, 0x0
ushr-int/lit8 v2, p0, 0x8
int-to-byte v2, v2
aput-byte v2, v0, v1
const/4 v1, 0x1
int-to-byte v2, p0
aput-byte v2, v0, v1
return-object v0
.end method
.method public static tlv2ToByteArray(Ljava/lang/String;)[B
.registers 7
const/4 v5, 0x0
const/4 v4, 0x2
if-eqz p0, :cond_c
const-string v0, ""
invoke-virtual {v0, p0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z
move-result v0
if-eqz v0, :cond_12
:cond_c
new-array v0, v4, [B
fill-array-data v0, :array_36
:goto_11
return-object v0
:cond_12
const/4 v0, 0x0
:try_start_13
const-string v1, "UTF-8"
invoke-virtual {p0, v1}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B
:try_end_18
.catch Ljava/io/UnsupportedEncodingException; {:try_start_13 .. :try_end_18} :catch_22
move-result-object v0
move-object v1, v0
:goto_1a
if-nez v1, :cond_25
new-array v0, v4, [B
fill-array-data v0, :array_3c
goto :goto_11
:catch_22
move-exception v1
move-object v1, v0
goto :goto_1a
:cond_25
array-length v0, v1
int-to-short v2, v0
add-int/lit8 v0, v2, 0x2
new-array v0, v0, [B
invoke-static {v2}, Lcn/jiguang/api/utils/ProtocolUtil;->short2ByteArray(S)[B
move-result-object v3
invoke-static {v3, v5, v0, v5, v4}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
invoke-static {v1, v5, v0, v4, v2}, Ljava/lang/System;->arraycopy(Ljava/lang/Object;ILjava/lang/Object;II)V
goto :goto_11
:array_36
.array-data 1
0x0t
0x0t
.end array-data
nop
:array_3c
.array-data 1
0x0t
0x0t
.end array-data
.end method