MCPcopy Create free account
hub / github.com/google/gapid / decode

Method decode

core/os/android/binaryxml/string_pool.go:69–113  ·  view source on GitHub ↗
(header, data []byte)

Source from the content-addressed store, hash-verified

67}
68
69func (c *stringPool) decode(header, data []byte) error {
70 const sortedFlag = 1 << 0
71 const utf8Flag = 1 << 8
72
73 // dataOffset is the offset of data relative to the start of the chunk.
74 dataOffset := 8 + uint32(len(header))
75
76 r := endian.Reader(bytes.NewReader(header), device.LittleEndian)
77 stringCount := r.Uint32()
78 styleCount := r.Uint32()
79 c.flags = r.Uint32()
80 stringsStart := r.Uint32() - dataOffset
81 stylesStart := r.Uint32() - dataOffset
82
83 r = endian.Reader(bytes.NewReader(data), device.LittleEndian)
84 indices := make([]uint32, stringCount)
85 for i := range indices {
86 indices[i] = r.Uint32()
87 }
88
89 c.ptrs = make([]int, stringCount)
90 c.strings = make([]string, stringCount)
91 c.styles = make([]string, styleCount)
92 for i := range c.strings {
93 offset := stringsStart + indices[i]
94 r = endian.Reader(bytes.NewReader(data[offset:]), device.LittleEndian)
95 if c.flags&utf8Flag != 0 {
96 panic("TODO: UTF8 encoded xml support.")
97 } else {
98 runeCount := decodeLength(r)
99 str := make([]uint16, runeCount)
100 for i := range str {
101 str[i] = r.Uint16()
102 }
103 c.strings[i] = string(utf16.Decode(str))
104 c.ptrs[i] = i
105 }
106 }
107 if styleCount > 0 {
108 _ = stylesStart
109 panic("TODO: Style decoding")
110 }
111
112 return nil
113}
114
115func (stringPool) xml(*xmlContext) string { return "" }
116

Callers

nothing calls this directly

Calls 6

decodeLengthFunction · 0.85
ReaderMethod · 0.65
NewReaderMethod · 0.65
Uint32Method · 0.65
Uint16Method · 0.65
DecodeMethod · 0.65

Tested by

no test coverage detected