Search in sources :

Example 1 with DexClassInfo

use of com.tencent.tinker.build.util.DexClassesComparator.DexClassInfo in project tinker by Tencent.

the class DexDiffDecoder method checkDexChange.

private void checkDexChange(Dex originDex, Dex newDex) {
    DexClassesComparator classesCmptor = new DexClassesComparator("*");
    classesCmptor.setIgnoredRemovedClassDescPattern(config.mDexLoaderPattern);
    classesCmptor.startCheck(originDex, newDex);
    List<DexClassInfo> addedClassInfos = classesCmptor.getAddedClassInfos();
    boolean isNoClassesAdded = addedClassInfos.isEmpty();
    Map<String, DexClassInfo[]> changedClassDescToClassInfosMap;
    boolean isNoClassesChanged;
    if (isNoClassesAdded) {
        changedClassDescToClassInfosMap = classesCmptor.getChangedClassDescToInfosMap();
        isNoClassesChanged = changedClassDescToClassInfosMap.isEmpty();
    } else {
        throw new TinkerPatchException("some classes was unexpectedly added in patched new dex, check if there's any bugs in " + "patch algorithm. Related classes: " + Utils.collectionToString(addedClassInfos));
    }
    if (isNoClassesChanged) {
        List<DexClassInfo> deletedClassInfos = classesCmptor.getDeletedClassInfos();
        if (!deletedClassInfos.isEmpty()) {
            throw new TinkerPatchException("some classes that are not matched to loader class pattern " + "was unexpectedly deleted in patched new dex, check if there's any bugs in " + "patch algorithm. Related classes: " + Utils.collectionToString(deletedClassInfos));
        }
    } else {
        throw new TinkerPatchException("some classes was unexpectedly changed in patched new dex, check if there's any bugs in " + "patch algorithm. Related classes: " + Utils.collectionToString(changedClassDescToClassInfosMap.keySet()));
    }
}
Also used : DexClassesComparator(com.tencent.tinker.build.util.DexClassesComparator) DexClassInfo(com.tencent.tinker.build.util.DexClassesComparator.DexClassInfo) TinkerPatchException(com.tencent.tinker.build.util.TinkerPatchException)

Aggregations

DexClassesComparator (com.tencent.tinker.build.util.DexClassesComparator)1 DexClassInfo (com.tencent.tinker.build.util.DexClassesComparator.DexClassInfo)1 TinkerPatchException (com.tencent.tinker.build.util.TinkerPatchException)1