Search in sources :

Example 1 with ResPackage

use of com.tencent.mm.androlib.res.data.ResPackage in project AndResGuard by shwenzhang.

the class ARSCDecoder method decode.

public static ResPackage[] decode(InputStream arscStream, ApkDecoder apkDecoder) throws AndrolibException {
    try {
        ARSCDecoder decoder = new ARSCDecoder(arscStream, apkDecoder);
        ResPackage[] pkgs = decoder.readTable();
        return pkgs;
    } catch (IOException ex) {
        throw new AndrolibException("Could not decode arsc file", ex);
    }
}
Also used : AndrolibException(com.tencent.mm.androlib.AndrolibException) IOException(java.io.IOException) ResPackage(com.tencent.mm.androlib.res.data.ResPackage)

Example 2 with ResPackage

use of com.tencent.mm.androlib.res.data.ResPackage in project AndResGuard by shwenzhang.

the class RawARSCDecoder method decode.

public static ResPackage[] decode(InputStream arscStream) throws AndrolibException {
    try {
        RawARSCDecoder decoder = new RawARSCDecoder(arscStream);
        System.out.printf("parse to get the exist names in the resouces.arsc first\n");
        ResPackage[] pkgs = decoder.readTable();
        return pkgs;
    } catch (IOException ex) {
        throw new AndrolibException("Could not decode arsc file", ex);
    }
}
Also used : AndrolibException(com.tencent.mm.androlib.AndrolibException) IOException(java.io.IOException) ResPackage(com.tencent.mm.androlib.res.data.ResPackage)

Example 3 with ResPackage

use of com.tencent.mm.androlib.res.data.ResPackage in project AndResGuard by shwenzhang.

the class ARSCDecoder method readPackage.

private ResPackage readPackage() throws IOException, AndrolibException {
    checkChunkType(Header.TYPE_PACKAGE);
    int id = (byte) mIn.readInt();
    String name = mIn.readNullEndedString(128, true);
    System.out.printf("reading packagename %s\n", name);
    /* typeNameStrings */
    mIn.skipInt();
    /* typeNameCount */
    mIn.skipInt();
    /* specNameStrings */
    mIn.skipInt();
    /* specNameCount */
    mIn.skipInt();
    mCurTypeID = -1;
    mTypeNames = StringBlock.read(mIn);
    mSpecNames = StringBlock.read(mIn);
    mResId = id << 24;
    mPkg = new ResPackage(id, name);
    //系统包名不混淆
    if (mPkg.getName().equals("android")) {
        mPkg.setCanProguard(false);
    } else {
        mPkg.setCanProguard(true);
    }
    nextChunk();
    while (mHeader.type == Header.TYPE_LIBRARY) {
        readLibraryType();
    }
    while (mHeader.type == Header.TYPE_SPEC_TYPE) {
        readTableTypeSpec();
    }
    return mPkg;
}
Also used : ResPackage(com.tencent.mm.androlib.res.data.ResPackage)

Example 4 with ResPackage

use of com.tencent.mm.androlib.res.data.ResPackage in project AndResGuard by shwenzhang.

the class ARSCDecoder method writeEntry.

private void writeEntry() throws IOException, AndrolibException {
    /* size */
    mOut.writeBytes(mIn, 2);
    short flags = mIn.readShort();
    mOut.writeShort(flags);
    int specNamesId = mIn.readInt();
    ResPackage pkg = mPkgs[mCurPackageID];
    if (pkg.isCanProguard()) {
        specNamesId = mCurSpecNameToPos.get(pkg.getSpecRepplace(mResId));
        if (specNamesId < 0) {
            throw new AndrolibException(String.format("writeEntry new specNamesId < 0 %d", specNamesId));
        }
    }
    mOut.writeInt(specNamesId);
    if ((flags & ENTRY_FLAG_COMPLEX) == 0) {
        writeValue();
    } else {
        writeComplexEntry();
    }
}
Also used : AndrolibException(com.tencent.mm.androlib.AndrolibException) ResPackage(com.tencent.mm.androlib.res.data.ResPackage)

Example 5 with ResPackage

use of com.tencent.mm.androlib.res.data.ResPackage in project AndResGuard by shwenzhang.

the class RawARSCDecoder method readPackage.

private ResPackage readPackage() throws IOException, AndrolibException {
    checkChunkType(Header.TYPE_PACKAGE);
    int id = (byte) mIn.readInt();
    String name = mIn.readNullEndedString(128, true);
    //add log
    /* typeNameStrings */
    mIn.skipInt();
    /* typeNameCount */
    mIn.skipInt();
    /* specNameStrings */
    mIn.skipInt();
    /* specNameCount */
    mIn.skipInt();
    mTypeNames = StringBlock.read(mIn);
    mSpecNames = StringBlock.read(mIn);
    mResId = id << 24;
    mPkg = new ResPackage(id, name);
    nextChunk();
    while (mHeader.type == Header.TYPE_LIBRARY) {
        readLibraryType();
    }
    while (mHeader.type == Header.TYPE_SPEC_TYPE) {
        readTableTypeSpec();
    }
    return mPkg;
}
Also used : ResPackage(com.tencent.mm.androlib.res.data.ResPackage)

Aggregations

ResPackage (com.tencent.mm.androlib.res.data.ResPackage)5 AndrolibException (com.tencent.mm.androlib.AndrolibException)3 IOException (java.io.IOException)2