@@ -55,11 +55,11 @@ public static StringBlock readWithoutChunk(ExtCountingDataInput reader, int star
55
55
}
56
56
57
57
StringBlock block = new StringBlock ();
58
- block .m_isUTF8 = (flags & UTF8_FLAG ) != 0 ;
59
- block .m_stringOffsets = reader .readSafeIntArray (stringCount , startPosition + stringsOffset );
58
+ block .mIsUtf8 = (flags & UTF8_FLAG ) != 0 ;
59
+ block .mStringOffsets = reader .readSafeIntArray (stringCount , startPosition + stringsOffset );
60
60
61
61
if (styleCount != 0 ) {
62
- block .m_styleOffsets = reader .readSafeIntArray (styleCount , startPosition + stylesOffset );
62
+ block .mStyleOffsets = reader .readSafeIntArray (styleCount , startPosition + stylesOffset );
63
63
}
64
64
65
65
// #3236 - Some applications give a style offset, but have 0 styles. Make this check more robust.
@@ -72,12 +72,12 @@ public static StringBlock readWithoutChunk(ExtCountingDataInput reader, int star
72
72
size = stylesOffset - stringsOffset ;
73
73
}
74
74
75
- block .m_strings = new byte [size ];
76
- reader .readFully (block .m_strings );
75
+ block .mStrings = new byte [size ];
76
+ reader .readFully (block .mStrings );
77
77
78
78
if (hasStyles ) {
79
79
size = chunkSize - stylesOffset ;
80
- block .m_styles = reader .readIntArray (size / 4 );
80
+ block .mStyles = reader .readIntArray (size / 4 );
81
81
}
82
82
83
83
// In case we aren't 4 byte aligned we need to skip the remaining bytes.
@@ -97,18 +97,18 @@ public static StringBlock readWithoutChunk(ExtCountingDataInput reader, int star
97
97
* @return String
98
98
*/
99
99
public String getString (int index ) {
100
- if (index < 0 || m_stringOffsets == null || index >= m_stringOffsets .length ) {
100
+ if (index < 0 || mStringOffsets == null || index >= mStringOffsets .length ) {
101
101
return null ;
102
102
}
103
- int offset = m_stringOffsets [index ];
103
+ int offset = mStringOffsets [index ];
104
104
int length ;
105
105
106
106
int [] val ;
107
- if (m_isUTF8 ) {
108
- val = getUtf8 (m_strings , offset );
107
+ if (mIsUtf8 ) {
108
+ val = getUtf8 (mStrings , offset );
109
109
offset = val [0 ];
110
110
} else {
111
- val = getUtf16 (m_strings , offset );
111
+ val = getUtf16 (mStrings , offset );
112
112
offset += val [0 ];
113
113
}
114
114
length = val [1 ];
@@ -155,16 +155,16 @@ public int find(String string) {
155
155
if (string == null ) {
156
156
return -1 ;
157
157
}
158
- for (int i = 0 ; i != m_stringOffsets .length ; ++i ) {
159
- int offset = m_stringOffsets [i ];
160
- int length = getShort (m_strings , offset );
158
+ for (int i = 0 ; i != mStringOffsets .length ; ++i ) {
159
+ int offset = mStringOffsets [i ];
160
+ int length = getShort (mStrings , offset );
161
161
if (length != string .length ()) {
162
162
continue ;
163
163
}
164
164
int j = 0 ;
165
165
for (; j != length ; ++j ) {
166
166
offset += 2 ;
167
- if (string .charAt (j ) != getShort (m_strings , offset )) {
167
+ if (string .charAt (j ) != getShort (mStrings , offset )) {
168
168
break ;
169
169
}
170
170
}
@@ -180,8 +180,8 @@ private StringBlock() {
180
180
181
181
@ VisibleForTesting
182
182
StringBlock (byte [] strings , boolean isUTF8 ) {
183
- m_strings = strings ;
184
- m_isUTF8 = isUTF8 ;
183
+ mStrings = strings ;
184
+ mIsUtf8 = isUTF8 ;
185
185
}
186
186
187
187
/**
@@ -190,15 +190,15 @@ private StringBlock() {
190
190
* start index in string * third int is tag end index in string
191
191
*/
192
192
private int [] getStyle (int index ) {
193
- if (m_styleOffsets == null || m_styles == null || index >= m_styleOffsets .length ) {
193
+ if (mStyleOffsets == null || mStyles == null || index >= mStyleOffsets .length ) {
194
194
return null ;
195
195
}
196
- int offset = m_styleOffsets [index ] / 4 ;
196
+ int offset = mStyleOffsets [index ] / 4 ;
197
197
int count = 0 ;
198
198
int [] style ;
199
199
200
- for (int i = offset ; i < m_styles .length ; ++i ) {
201
- if (m_styles [i ] == -1 ) {
200
+ for (int i = offset ; i < mStyles .length ; ++i ) {
201
+ if (mStyles [i ] == -1 ) {
202
202
break ;
203
203
}
204
204
count += 1 ;
@@ -209,34 +209,34 @@ private int[] getStyle(int index) {
209
209
}
210
210
style = new int [count ];
211
211
212
- for (int i = offset , j = 0 ; i < m_styles .length ;) {
213
- if (m_styles [i ] == -1 ) {
212
+ for (int i = offset , j = 0 ; i < mStyles .length ;) {
213
+ if (mStyles [i ] == -1 ) {
214
214
break ;
215
215
}
216
- style [j ++] = m_styles [i ++];
216
+ style [j ++] = mStyles [i ++];
217
217
}
218
218
return style ;
219
219
}
220
220
221
221
@ VisibleForTesting
222
222
String decodeString (int offset , int length ) {
223
223
try {
224
- final ByteBuffer wrappedBuffer = ByteBuffer .wrap (m_strings , offset , length );
225
- return (m_isUTF8 ? UTF8_DECODER : UTF16LE_DECODER ).decode (wrappedBuffer ).toString ();
224
+ final ByteBuffer wrappedBuffer = ByteBuffer .wrap (mStrings , offset , length );
225
+ return (mIsUtf8 ? UTF8_DECODER : UTF16LE_DECODER ).decode (wrappedBuffer ).toString ();
226
226
} catch (CharacterCodingException ex ) {
227
- if (!m_isUTF8 ) {
227
+ if (!mIsUtf8 ) {
228
228
LOGGER .warning ("Failed to decode a string at offset " + offset + " of length " + length );
229
229
return null ;
230
230
}
231
231
} catch (IndexOutOfBoundsException ex ) {
232
- if (!m_isUTF8 ) {
232
+ if (!mIsUtf8 ) {
233
233
LOGGER .warning ("String extends outside of pool at " + offset + " of length " + length );
234
234
return null ;
235
235
}
236
236
}
237
237
238
238
try {
239
- final ByteBuffer wrappedBufferRetry = ByteBuffer .wrap (m_strings , offset , length );
239
+ final ByteBuffer wrappedBufferRetry = ByteBuffer .wrap (mStrings , offset , length );
240
240
// in some places, Android uses 3-byte UTF-8 sequences instead of 4-bytes.
241
241
// If decoding failed, we try to use CESU-8 decoder, which is closer to what Android actually uses.
242
242
return CESU8_DECODER .decode (wrappedBufferRetry ).toString ();
@@ -285,11 +285,11 @@ private static int[] getUtf16(byte[] array, int offset) {
285
285
return new int [] {2 , val * 2 };
286
286
}
287
287
288
- private int [] m_stringOffsets ;
289
- private byte [] m_strings ;
290
- private int [] m_styleOffsets ;
291
- private int [] m_styles ;
292
- private boolean m_isUTF8 ;
288
+ private int [] mStringOffsets ;
289
+ private byte [] mStrings ;
290
+ private int [] mStyleOffsets ;
291
+ private int [] mStyles ;
292
+ private boolean mIsUtf8 ;
293
293
294
294
private final CharsetDecoder UTF16LE_DECODER = StandardCharsets .UTF_16LE .newDecoder ();
295
295
private final CharsetDecoder UTF8_DECODER = StandardCharsets .UTF_8 .newDecoder ();
0 commit comments