Skip to content

Commit bdaee54

Browse files
authored
fix: support empty value for zero flags (#4140)
1 parent 4c91962 commit bdaee54

6 files changed

Lines changed: 33 additions & 5 deletions

File tree

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/StyledString.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,10 @@ public int getFirstChar() {
9898
public int getLastChar() {
9999
return mLastChar;
100100
}
101+
102+
@Override
103+
public String toString() {
104+
return String.format("Span{tag=%s, firstChar=%s, lastChar=%s}", mTag, mFirstChar, mLastChar);
105+
}
101106
}
102107
}

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResAttribute.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ public ResReference getKey() {
146146
public ResPrimitive getValue() {
147147
return mValue;
148148
}
149+
150+
@Override
151+
public String toString() {
152+
return String.format("Symbol{key=%s, value=%s}", mKey, mValue);
153+
}
149154
}
150155

151156
public void addValueType(int valueType) {

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResBag.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public int getKey() {
6363
public ResItem getValue() {
6464
return mValue;
6565
}
66+
67+
@Override
68+
public String toString() {
69+
return String.format("RawItem{key=0x%08x, value=%s}", mKey, mValue);
70+
}
6671
}
6772

6873
public void resolveKeys() throws AndrolibException {

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResEnum.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,13 @@ private Symbol[] getSymbols(int data) {
109109
}
110110
}
111111

112+
// Stop early if the value is missing a symbol.
112113
if (symbolsCount == 0) {
113-
symbols = null;
114-
} else if (symbolsCount < symbols.length) {
114+
mSymbolsCache.put(data, null);
115+
return null;
116+
}
117+
118+
if (symbolsCount < symbols.length) {
115119
symbols = Arrays.copyOf(symbols, symbolsCount);
116120
}
117121

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResFlags.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ private Symbol[] getSymbols(int data) {
139139
}
140140
}
141141

142+
// Stop early if any of the flags are missing a symbol.
143+
if (mask != data) {
144+
mSymbolsCache.put(data, null);
145+
return null;
146+
}
147+
142148
// Filter out redundant flags.
143149
if (symbolsCount > 2) {
144150
Symbol[] filtered = new Symbol[symbolsCount];
@@ -170,9 +176,7 @@ private Symbol[] getSymbols(int data) {
170176
}
171177
}
172178

173-
if (symbolsCount == 0) {
174-
symbols = null;
175-
} else if (symbolsCount < symbols.length) {
179+
if (symbolsCount < symbols.length) {
176180
symbols = Arrays.copyOf(symbols, symbolsCount);
177181
}
178182

brut.apktool/apktool-lib/src/main/java/brut/androlib/res/table/value/ResStyle.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public ResReference getKey() {
7676
public ResItem getValue() {
7777
return mValue;
7878
}
79+
80+
@Override
81+
public String toString() {
82+
return String.format("Item{key=%s, value=%s}", mKey, mValue);
83+
}
7984
}
8085

8186
@Override

0 commit comments

Comments
 (0)