AXML中的node header

总的来说,AXML是以一个个的node组织在一块的,AXMLPrinter的code中称为trunk。

我们来看AXMLPrinter中的相关code:

            chunkType=m_reader.readInt(); 

            // Common header.

            m_chunkSize = m_reader.readInt();

            int lineNumber=m_reader.readInt();

            /*0xFFFFFFFF*/m_reader.skipInt();

 

这4个字段实际上对应到Android源码中的ResXMLTree_node结构:

struct ResXMLTree_node

{

    struct ResChunk_header header;

 

    // Line number in original source file atwhich this element appeared.

    uint32_t lineNumber;

 

    // Optional XML comment that was associatedwith this element; -1 if none.

    struct ResStringPool_ref comment;

};

 

struct ResChunk_header
{
    // Type identifier for this chunk.  The meaning of this value depends
    // on the containing chunk.
    uint16_t type;
 
    // Size of the chunk header (in bytes).  Adding this value to
    // the address of the chunk allows you to find its associated data
    // (if any).
    uint16_t headerSize;
 
    // Total size of this chunk (in bytes).  This is the chunkSize plus
    // the size of any data associated with the chunk.  Adding this value
    // to the chunk allows you to completely skip its contents (including
    // any child chunks).  If this value is the same as chunkSize, there is
    // no data associated with the chunk.
    uint32_t size;
};

 

可以看到,这里的解析跟源码还略有差异,AXMLPrinterCHUNK_XML_START_TAG定义为0x100102,实际上,该tag是一个16位的整形0x0102,只是因为headerSize固定为16字节,即0x0010,所以AXMLPrinter的实现才没问题。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值