Skip to content

Commit bb9519a

Browse files
authored
refactor: change naming pattern of class variables in StringBlock (#3256)
1 parent 2549fe9 commit bb9519a

File tree

1 file changed

+34
-34
lines changed
  • brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder

1 file changed

+34
-34
lines changed

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/decoder/StringBlock.java

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ public static StringBlock readWithoutChunk(ExtCountingDataInput reader, int star
5555
}
5656

5757
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);
6060

6161
if (styleCount != 0) {
62-
block.m_styleOffsets = reader.readSafeIntArray(styleCount, startPosition + stylesOffset);
62+
block.mStyleOffsets = reader.readSafeIntArray(styleCount, startPosition + stylesOffset);
6363
}
6464

6565
// #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
7272
size = stylesOffset - stringsOffset;
7373
}
7474

75-
block.m_strings = new byte[size];
76-
reader.readFully(block.m_strings);
75+
block.mStrings = new byte[size];
76+
reader.readFully(block.mStrings);
7777

7878
if (hasStyles) {
7979
size = chunkSize - stylesOffset;
80-
block.m_styles = reader.readIntArray(size / 4);
80+
block.mStyles = reader.readIntArray(size / 4);
8181
}
8282

8383
// 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
9797
* @return String
9898
*/
9999
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) {
101101
return null;
102102
}
103-
int offset = m_stringOffsets[index];
103+
int offset = mStringOffsets[index];
104104
int length;
105105

106106
int[] val;
107-
if (m_isUTF8) {
108-
val = getUtf8(m_strings, offset);
107+
if (mIsUtf8) {
108+
val = getUtf8(mStrings, offset);
109109
offset = val[0];
110110
} else {
111-
val = getUtf16(m_strings, offset);
111+
val = getUtf16(mStrings, offset);
112112
offset += val[0];
113113
}
114114
length = val[1];
@@ -155,16 +155,16 @@ public int find(String string) {
155155
if (string == null) {
156156
return -1;
157157
}
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);
161161
if (length != string.length()) {
162162
continue;
163163
}
164164
int j = 0;
165165
for (; j != length; ++j) {
166166
offset += 2;
167-
if (string.charAt(j) != getShort(m_strings, offset)) {
167+
if (string.charAt(j) != getShort(mStrings, offset)) {
168168
break;
169169
}
170170
}
@@ -180,8 +180,8 @@ private StringBlock() {
180180

181181
@VisibleForTesting
182182
StringBlock(byte[] strings, boolean isUTF8) {
183-
m_strings = strings;
184-
m_isUTF8 = isUTF8;
183+
mStrings = strings;
184+
mIsUtf8 = isUTF8;
185185
}
186186

187187
/**
@@ -190,15 +190,15 @@ private StringBlock() {
190190
* start index in string * third int is tag end index in string
191191
*/
192192
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) {
194194
return null;
195195
}
196-
int offset = m_styleOffsets[index] / 4;
196+
int offset = mStyleOffsets[index] / 4;
197197
int count = 0;
198198
int[] style;
199199

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) {
202202
break;
203203
}
204204
count += 1;
@@ -209,34 +209,34 @@ private int[] getStyle(int index) {
209209
}
210210
style = new int[count];
211211

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) {
214214
break;
215215
}
216-
style[j++] = m_styles[i++];
216+
style[j++] = mStyles[i++];
217217
}
218218
return style;
219219
}
220220

221221
@VisibleForTesting
222222
String decodeString(int offset, int length) {
223223
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();
226226
} catch (CharacterCodingException ex) {
227-
if (!m_isUTF8) {
227+
if (!mIsUtf8) {
228228
LOGGER.warning("Failed to decode a string at offset " + offset + " of length " + length);
229229
return null;
230230
}
231231
} catch (IndexOutOfBoundsException ex) {
232-
if (!m_isUTF8) {
232+
if (!mIsUtf8) {
233233
LOGGER.warning("String extends outside of pool at " + offset + " of length " + length);
234234
return null;
235235
}
236236
}
237237

238238
try {
239-
final ByteBuffer wrappedBufferRetry = ByteBuffer.wrap(m_strings, offset, length);
239+
final ByteBuffer wrappedBufferRetry = ByteBuffer.wrap(mStrings, offset, length);
240240
// in some places, Android uses 3-byte UTF-8 sequences instead of 4-bytes.
241241
// If decoding failed, we try to use CESU-8 decoder, which is closer to what Android actually uses.
242242
return CESU8_DECODER.decode(wrappedBufferRetry).toString();
@@ -285,11 +285,11 @@ private static int[] getUtf16(byte[] array, int offset) {
285285
return new int[] {2, val * 2};
286286
}
287287

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;
293293

294294
private final CharsetDecoder UTF16LE_DECODER = StandardCharsets.UTF_16LE.newDecoder();
295295
private final CharsetDecoder UTF8_DECODER = StandardCharsets.UTF_8.newDecoder();

0 commit comments

Comments
 (0)