DexSectionPatchAlgorithm.smali
.class public abstract Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;
.super Ljava/lang/Object;
# annotations
.annotation system Ldalvik/annotation/Signature;
value = {
"<T::",
"Ljava/lang/Comparable",
"<TT;>;>",
"Ljava/lang/Object;"
}
.end annotation
# instance fields
.field protected final oldDex:Lcom/tencent/tinker/android/dex/Dex;
.field private final oldToPatchedIndexMap:Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;
.field protected final patchFile:Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;
# direct methods
.method public constructor <init>(Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;Lcom/tencent/tinker/android/dex/Dex;Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;)V
.registers 4
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
iput-object p1, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->patchFile:Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;
iput-object p2, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->oldDex:Lcom/tencent/tinker/android/dex/Dex;
iput-object p3, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->oldToPatchedIndexMap:Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;
return-void
.end method
.method private doFullPatch(Lcom/tencent/tinker/android/dex/Dex$Section;I[I[I[I)V
.registers 20
move-object/from16 v0, p3
array-length v10, v0
move-object/from16 v0, p4
array-length v11, v0
move-object/from16 v0, p5
array-length v12, v0
add-int v1, p2, v11
sub-int v13, v1, v10
const/4 v4, 0x0
const/4 v2, 0x0
const/4 v1, 0x0
const/4 v3, 0x0
const/4 v5, 0x0
move v7, v1
move v8, v2
move v9, v4
:cond_15
:goto_15
move/from16 v0, p2
if-lt v3, v0, :cond_1b
if-ge v5, v13, :cond_a2
:cond_1b
if-ge v8, v11, :cond_34
aget v1, p4, v8
if-ne v1, v5, :cond_34
iget-object v1, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->patchFile:Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;
invoke-virtual {v1}, Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;->getBuffer()Lcom/tencent/tinker/android/dex/io/DexDataBuffer;
move-result-object v1
invoke-virtual {p0, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->nextItem(Lcom/tencent/tinker/android/dex/io/DexDataBuffer;)Ljava/lang/Comparable;
move-result-object v1
invoke-virtual {p0, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->writePatchedItem(Ljava/lang/Comparable;)I
add-int/lit8 v1, v8, 0x1
add-int/lit8 v5, v5, 0x1
move v8, v1
goto :goto_15
:cond_34
if-ge v7, v12, :cond_4d
aget v1, p5, v7
if-ne v1, v5, :cond_4d
iget-object v1, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->patchFile:Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;
invoke-virtual {v1}, Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;->getBuffer()Lcom/tencent/tinker/android/dex/io/DexDataBuffer;
move-result-object v1
invoke-virtual {p0, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->nextItem(Lcom/tencent/tinker/android/dex/io/DexDataBuffer;)Ljava/lang/Comparable;
move-result-object v1
invoke-virtual {p0, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->writePatchedItem(Ljava/lang/Comparable;)I
add-int/lit8 v1, v7, 0x1
add-int/lit8 v5, v5, 0x1
move v7, v1
goto :goto_15
:cond_4d
move-object/from16 v0, p3
invoke-static {v0, v3}, Ljava/util/Arrays;->binarySearch([II)I
move-result v1
if-ltz v1, :cond_68
invoke-virtual {p0, p1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->nextItem(Lcom/tencent/tinker/android/dex/io/DexDataBuffer;)Ljava/lang/Comparable;
move-result-object v1
iget-object v2, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->oldToPatchedIndexMap:Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;
invoke-direct {p0, v3, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->getItemOffsetOrIndex(ILjava/lang/Comparable;)I
move-result v1
invoke-virtual {p0, v2, v3, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->markDeletedIndexOrOffset(Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;II)V
add-int/lit8 v3, v3, 0x1
add-int/lit8 v1, v9, 0x1
move v9, v1
goto :goto_15
:cond_68
move-object/from16 v0, p5
invoke-static {v0, v3}, Ljava/util/Arrays;->binarySearch([II)I
move-result v1
if-ltz v1, :cond_80
invoke-virtual {p0, p1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->nextItem(Lcom/tencent/tinker/android/dex/io/DexDataBuffer;)Ljava/lang/Comparable;
move-result-object v1
iget-object v2, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->oldToPatchedIndexMap:Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;
invoke-direct {p0, v3, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->getItemOffsetOrIndex(ILjava/lang/Comparable;)I
move-result v1
invoke-virtual {p0, v2, v3, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->markDeletedIndexOrOffset(Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;II)V
add-int/lit8 v3, v3, 0x1
goto :goto_15
:cond_80
move/from16 v0, p2
if-ge v3, v0, :cond_15
iget-object v1, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->oldToPatchedIndexMap:Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;
invoke-virtual {p0, p1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->nextItem(Lcom/tencent/tinker/android/dex/io/DexDataBuffer;)Ljava/lang/Comparable;
move-result-object v2
invoke-virtual {p0, v1, v2}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->adjustItem(Lcom/tencent/tinker/commons/dexpatcher/util/AbstractIndexMap;Ljava/lang/Comparable;)Ljava/lang/Comparable;
move-result-object v1
invoke-virtual {p0, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->writePatchedItem(Ljava/lang/Comparable;)I
move-result v6
iget-object v2, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->oldToPatchedIndexMap:Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;
invoke-direct {p0, v3, v1}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->getItemOffsetOrIndex(ILjava/lang/Comparable;)I
move-result v4
move-object v1, p0
invoke-virtual/range {v1 .. v6}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->updateIndexOrOffset(Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;IIII)V
add-int/lit8 v3, v3, 0x1
add-int/lit8 v5, v5, 0x1
goto/16 :goto_15
:cond_a2
if-ne v8, v11, :cond_a8
if-ne v9, v10, :cond_a8
if-eq v7, v12, :cond_e2
:cond_a8
new-instance v1, Ljava/lang/IllegalStateException;
const-string/jumbo v2, "bad patch operation sequence. addCounter: %d, addCount: %d, delCounter: %d, delCount: %d, replaceCounter: %d, replaceCount:%d"
const/4 v3, 0x6
new-array v3, v3, [Ljava/lang/Object;
const/4 v4, 0x0
invoke-static {v8}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v5
aput-object v5, v3, v4
const/4 v4, 0x1
invoke-static {v11}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v5
aput-object v5, v3, v4
const/4 v4, 0x2
invoke-static {v9}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v5
aput-object v5, v3, v4
const/4 v4, 0x3
invoke-static {v10}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v5
aput-object v5, v3, v4
const/4 v4, 0x4
invoke-static {v7}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v5
aput-object v5, v3, v4
const/4 v4, 0x5
invoke-static {v12}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
move-result-object v5
aput-object v5, v3, v4
invoke-static {v2, v3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v2
invoke-direct {v1, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v1
:cond_e2
return-void
.end method
.method private getItemOffsetOrIndex(ILjava/lang/Comparable;)I
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"(ITT;)I"
}
.end annotation
instance-of v0, p2, Lcom/tencent/tinker/android/dex/TableOfContents$Section$Item;
if-eqz v0, :cond_8
check-cast p2, Lcom/tencent/tinker/android/dex/TableOfContents$Section$Item;
iget p1, p2, Lcom/tencent/tinker/android/dex/TableOfContents$Section$Item;->off:I
:cond_8
return p1
.end method
.method private readDeltaIndiciesOrOffsets(I)[I
.registers 6
const/4 v0, 0x0
new-array v2, p1, [I
move v1, v0
:goto_4
if-ge v0, p1, :cond_16
iget-object v3, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->patchFile:Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;
invoke-virtual {v3}, Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;->getBuffer()Lcom/tencent/tinker/android/dex/io/DexDataBuffer;
move-result-object v3
invoke-virtual {v3}, Lcom/tencent/tinker/android/dex/io/DexDataBuffer;->readSleb128()I
move-result v3
add-int/2addr v1, v3
aput v1, v2, v0
add-int/lit8 v0, v0, 0x1
goto :goto_4
:cond_16
return-object v2
.end method
# virtual methods
.method protected adjustItem(Lcom/tencent/tinker/commons/dexpatcher/util/AbstractIndexMap;Ljava/lang/Comparable;)Ljava/lang/Comparable;
.registers 3
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/tencent/tinker/commons/dexpatcher/util/AbstractIndexMap;",
"TT;)TT;"
}
.end annotation
return-object p2
.end method
.method public execute()V
.registers 8
iget-object v0, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->patchFile:Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;
invoke-virtual {v0}, Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;->getBuffer()Lcom/tencent/tinker/android/dex/io/DexDataBuffer;
move-result-object v0
invoke-virtual {v0}, Lcom/tencent/tinker/android/dex/io/DexDataBuffer;->readUleb128()I
move-result v0
invoke-direct {p0, v0}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->readDeltaIndiciesOrOffsets(I)[I
move-result-object v3
iget-object v0, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->patchFile:Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;
invoke-virtual {v0}, Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;->getBuffer()Lcom/tencent/tinker/android/dex/io/DexDataBuffer;
move-result-object v0
invoke-virtual {v0}, Lcom/tencent/tinker/android/dex/io/DexDataBuffer;->readUleb128()I
move-result v0
invoke-direct {p0, v0}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->readDeltaIndiciesOrOffsets(I)[I
move-result-object v4
iget-object v0, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->patchFile:Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;
invoke-virtual {v0}, Lcom/tencent/tinker/commons/dexpatcher/struct/DexPatchFile;->getBuffer()Lcom/tencent/tinker/android/dex/io/DexDataBuffer;
move-result-object v0
invoke-virtual {v0}, Lcom/tencent/tinker/android/dex/io/DexDataBuffer;->readUleb128()I
move-result v0
invoke-direct {p0, v0}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->readDeltaIndiciesOrOffsets(I)[I
move-result-object v5
iget-object v0, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->oldDex:Lcom/tencent/tinker/android/dex/Dex;
invoke-virtual {p0, v0}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->getTocSection(Lcom/tencent/tinker/android/dex/Dex;)Lcom/tencent/tinker/android/dex/TableOfContents$Section;
move-result-object v0
const/4 v1, 0x0
const/4 v2, 0x0
invoke-virtual {v0}, Lcom/tencent/tinker/android/dex/TableOfContents$Section;->exists()Z
move-result v6
if-eqz v6, :cond_40
iget-object v1, p0, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->oldDex:Lcom/tencent/tinker/android/dex/Dex;
invoke-virtual {v1, v0}, Lcom/tencent/tinker/android/dex/Dex;->openSection(Lcom/tencent/tinker/android/dex/TableOfContents$Section;)Lcom/tencent/tinker/android/dex/Dex$Section;
move-result-object v1
iget v2, v0, Lcom/tencent/tinker/android/dex/TableOfContents$Section;->size:I
:cond_40
move-object v0, p0
invoke-direct/range {v0 .. v5}, Lcom/tencent/tinker/commons/dexpatcher/algorithms/patch/DexSectionPatchAlgorithm;->doFullPatch(Lcom/tencent/tinker/android/dex/Dex$Section;I[I[I[I)V
return-void
.end method
.method protected abstract getItemSize(Ljava/lang/Comparable;)I
.annotation system Ldalvik/annotation/Signature;
value = {
"(TT;)I"
}
.end annotation
.end method
.method protected abstract getTocSection(Lcom/tencent/tinker/android/dex/Dex;)Lcom/tencent/tinker/android/dex/TableOfContents$Section;
.end method
.method protected markDeletedIndexOrOffset(Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;II)V
.registers 4
return-void
.end method
.method protected abstract nextItem(Lcom/tencent/tinker/android/dex/io/DexDataBuffer;)Ljava/lang/Comparable;
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/tencent/tinker/android/dex/io/DexDataBuffer;",
")TT;"
}
.end annotation
.end method
.method protected updateIndexOrOffset(Lcom/tencent/tinker/commons/dexpatcher/util/SparseIndexMap;IIII)V
.registers 6
return-void
.end method
.method protected abstract writePatchedItem(Ljava/lang/Comparable;)I
.annotation system Ldalvik/annotation/Signature;
value = {
"(TT;)I"
}
.end annotation
.end method